Skip to content

Commit

Permalink
refactor(price): new PriceOwnerChip component (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Mar 14, 2024
1 parent b4ca17e commit 25dbd25
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/components/PriceFooter.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<template>
<div class="d-flex flex-wrap ga-1">
<PriceLocationChip v-if="!hidePriceLocation" :price="price" :readonly="readonly"></PriceLocationChip>

<v-chip label size="small" density="comfortable" @click="goToUser()">
<v-icon start icon="mdi-account"></v-icon>
{{ price.owner }}
</v-chip>

<PriceOwnerChip :price="price" :readonly="readonly"></PriceOwnerChip>
<RelativeDateTimeChip :dateTime="price.created"></RelativeDateTimeChip>

<PriceProof v-if="price.proof && price.proof.is_public && !hidePriceProof" :proof="price.proof"></PriceProof>

<PriceDeleteChip v-if="userIsPriceOwner" :price="price"></PriceDeleteChip>
</div>
</template>
Expand All @@ -24,6 +17,7 @@ import { defineAsyncComponent } from 'vue'
export default {
components: {
'PriceLocationChip': defineAsyncComponent(() => import('../components/PriceLocationChip.vue')),
'PriceOwnerChip': defineAsyncComponent(() => import('../components/PriceOwnerChip.vue')),
'RelativeDateTimeChip': defineAsyncComponent(() => import('../components/RelativeDateTimeChip.vue')),
'PriceProof': defineAsyncComponent(() => import('../components/PriceProof.vue')),
'PriceDeleteChip': defineAsyncComponent(() => import('../components/PriceDeleteChip.vue'))
Expand All @@ -42,14 +36,6 @@ export default {
userIsPriceOwner() {
return this.username && (this.price.owner === this.username)
}
},
methods: {
goToUser() {
if (this.readonly) {
return
}
this.$router.push({ path: `/users/${this.price.owner}` })
},
}
}
</script>
23 changes: 23 additions & 0 deletions src/components/PriceOwnerChip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<v-chip label size="small" density="comfortable" @click="goToUser()">
<v-icon start icon="mdi-account"></v-icon>
{{ price.owner }}
</v-chip>
</template>

<script>
export default {
props: {
'price': null,
'readonly': false
},
methods: {
goToUser() {
if (this.readonly) {
return
}
this.$router.push({ path: `/users/${this.price.owner}` })
},
}
}
</script>

0 comments on commit 25dbd25

Please sign in to comment.