feat: initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// 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)
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user