toggle favorite inspiration working + tab my favorite

This commit is contained in:
isUnknown 2024-09-11 08:05:35 +02:00
parent 0a412d48a4
commit 0ee0181206
6 changed files with 41 additions and 14 deletions

View file

@ -1,5 +1,9 @@
<template>
<figure class="flex" :style="'--rows: ' + (index % 2 ? 2 : 3)">
<figure
v-if="currentTab === 'all' || isFavorite"
class="flex"
:style="'--rows: ' + (index % 2 ? 2 : 3)"
>
<button
class="favorite"
aria-label="Ajouter aux favoris"
@ -34,6 +38,7 @@ import { useApiStore } from "../../stores/api";
const { item, inspirationUri } = defineProps({
item: Object,
inspirationUri: String,
currentTab: String,
});
const toggleFavoriteRoute = "/toggle-favorite.json";
@ -47,9 +52,9 @@ watch(isFavorite, (value) => {
userUuid: user.uuid,
inspirationUri,
};
api
.fetchRoute(toggleFavoriteRoute, "POST", data)
.then((res) => console.log(res));
api.fetchRoute(toggleFavoriteRoute, "POST", data).then((newValue) => {
item.favoriteForUsers = newValue;
});
});
</script>
<style scoped>