/ Fixed card assets and methods to work with new store (doesn't work yet)
This commit is contained in:
@@ -16,19 +16,19 @@
|
|||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
v-else-if="celestial.type === 'lune'"
|
v-else-if="celestial.type === 'lune'"
|
||||||
src="icons/moon-and-stars-in-a-cloud.svg"
|
src="/icons/moon-and-stars-in-a-cloud.svg"
|
||||||
class="fs-icon"
|
class="fs-icon"
|
||||||
alt="moon icon"
|
alt="moon icon"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
v-else-if="celestial.type === 'étoile'"
|
v-else-if="celestial.type === 'étoile'"
|
||||||
src="icons/sun-shape.svg"
|
src="/icons/sun-shape.svg"
|
||||||
class="fs-icon"
|
class="fs-icon"
|
||||||
alt="moon icon"
|
alt="moon icon"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
v-else
|
v-else
|
||||||
src="icons/stars-group.svg"
|
src="/icons/stars-group.svg"
|
||||||
alt="moon icon"
|
alt="moon icon"
|
||||||
class="fs-icon"
|
class="fs-icon"
|
||||||
>
|
>
|
||||||
@@ -96,12 +96,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { defineComponent } from '@vue/composition-api'
|
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
import store from '@/store'
|
export default {
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'CelestialCard',
|
name: 'CelestialCard',
|
||||||
props: {
|
props: {
|
||||||
celestial: {
|
celestial: {
|
||||||
@@ -116,17 +113,14 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isFav () {
|
isFav () {
|
||||||
if (store.getters.isFav(this.celestial?.id)) {
|
return this.$store.getters.isFav(this.celestial.id)
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleFav: (celestial) => {
|
toggleFav: (celestial) => {
|
||||||
store.dispatch('toggleFav', celestial.id)
|
this.$store.dispatch('toggleFav', celestial.id)
|
||||||
if (store.getters.isFav(celestial.id)) {
|
if (!this.isFav) {
|
||||||
store.dispatch('toasts/pushToast', {
|
this.$store.dispatch('toasts/pushToast', {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
title: 'Favori ajouté',
|
title: 'Favori ajouté',
|
||||||
message: `${celestial.name} a été ajouté à la liste des favoris.`,
|
message: `${celestial.name} a été ajouté à la liste des favoris.`,
|
||||||
@@ -134,7 +128,7 @@ export default defineComponent({
|
|||||||
timer: 3
|
timer: 3
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
store.dispatch('toasts/pushToast', {
|
this.$store.dispatch('toasts/pushToast', {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
title: 'Favori retiré',
|
title: 'Favori retiré',
|
||||||
message: `${celestial.name} a été retiré de la liste des favoris.`,
|
message: `${celestial.name} a été retiré de la liste des favoris.`,
|
||||||
@@ -144,7 +138,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user