Skip to content

Commit

Permalink
refactor(Price origin chip): translate chip content depending on user…
Browse files Browse the repository at this point in the history
… locale (#1218)
  • Loading branch information
raphodn authored Jan 1, 2025
1 parent e03c01b commit f900588
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/components/PriceOrigins.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<template>
<v-chip v-if="priceOrigins" label size="small" density="comfortable">
{{ priceOriginTagName }}
</v-chip>
<span v-if="priceOrigins">
<v-chip v-for="origin in priceOrigins" :key="origin" class="mr-1" label size="small" density="comfortable">
{{ getPriceOriginTagName(origin) }}
</v-chip>
</span>
</template>

<script>
import OriginTags from '../data/origins-tags.json'
import { mapStores } from 'pinia'
import { useAppStore } from '../store'
import utils from '../utils.js'
export default {
props: {
Expand All @@ -15,10 +19,24 @@ export default {
}
},
data() {
return {
originTags: [], // see mounted
}
},
computed: {
priceOriginTagName() {
return OriginTags.find(ot => this.priceOrigins[0].includes(ot.id)).name
},
...mapStores(useAppStore),
},
mounted() {
utils.getLocaleOriginTags(this.appStore.getUserLanguage).then((module) => {
this.originTags = module.default
})
},
methods: {
getPriceOriginTagName(originId) {
if (this.originTags.length === 0) return ''
return this.originTags.find(ot => ot.id === originId).name
}
}
}
</script>

0 comments on commit f900588

Please sign in to comment.