Skip to content

Commit

Permalink
chore: change import of proptype
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Feb 20, 2024
1 parent 843a021 commit ab7389e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
31 changes: 29 additions & 2 deletions components/Fields/Stars.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
<script lang="ts">
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import type { PropType } from 'vue'
import { defineNuxtComponent } from '#app'
enum StarsEnum {
One = '1',
OneS = '1S',
Two = '2',
TwoS = '2S',
Three = '3',
ThreeS = '3S',
Four = '4',
FourS = '4S',
Five = '5',
FiveS = '5S',
}
export default defineNuxtComponent({
components: {
FontAwesomeIcon,
},
props: {
stars: {
type: Number,
type: String as PropType<StarsEnum>,
required: true,
},
},
computed: {
isSNotation(): boolean {
return Boolean(this.stars.includes('S'))
},
numericProp(): number {
let stars: string = this.stars
if (this.isSNotation)
stars = this.stars.slice(0, -1)
return Number(stars)
},
},
})
</script>

<template>
<div class="stars-data tw-text-amber-500 tw-mb-1">
<FontAwesomeIcon
v-for="index in stars"
v-for="(_item, index) in numericProp"
:key="index"
icon="star"
/>
{{ isSNotation ? 'S' : '' }}
</div>
</template>
5 changes: 2 additions & 3 deletions stores/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ export const mapStore = defineStore('map', {
const cleanProperties: { [key: string]: any } = {}

Object.keys(feature.properties).forEach((key) => {
if (IsJsonString(feature.properties[key]))
if (key !== 'stars' && IsJsonString(feature.properties[key]))
cleanProperties[key] = JSON.parse(feature.properties[key])
else
cleanProperties[key] = feature.properties[key]
else cleanProperties[key] = feature.properties[key]
})

goodFeature.properties = cleanProperties as ApiPoiProperties
Expand Down

0 comments on commit ab7389e

Please sign in to comment.