Files
tehran_tala/apps/user-app/src/stores/favoritesStore.ts
T

23 lines
751 B
TypeScript
Raw Normal View History

2026-09-09 06:46:27 +03:30
// Adapted from legacy henza_pwa/src/Mixins/favorite.ts + the `favorits` slice of
// myDataStore. Legacy persisted favorites server-side via POST /add-to-fav; the
// new API has no favorites endpoint yet, so this is local-only (Pinia state,
// not persisted) until that backend support exists. Flagged — not a silent
// behavior match, a deliberate stand-in.
import { defineStore } from 'pinia'
export const useFavoritesStore = defineStore('favorites', {
state: () => ({
ids: [] as string[],
}),
actions: {
toggle(id: string) {
const index = this.ids.indexOf(id)
if (index === -1) this.ids.push(id)
else this.ids.splice(index, 1)
},
isFavorite(id: string) {
return this.ids.includes(id)
},
},
})