first commit

This commit is contained in:
2025-07-12 14:17:55 +02:00
commit f74eb98414
21 changed files with 8751 additions and 0 deletions

26
store/Card.ts Normal file
View File

@@ -0,0 +1,26 @@
import { defineStore } from "pinia";
import type { Card } from "~/types/Card";
export const useCardStore = defineStore("cardStore", {
state: () => ({
collections: [] as string[],
cards: [] as Card[],
}),
actions: {
async fetchCollections() {
const { data: collections } =
await useFetch<string[]>("/api/collections");
this.collections = collections.value ?? [];
},
async fetchCardsByCollection(collectionName: string) {
const response = useFetch<Card[]>(`/api/cards/${collectionName}`);
this.cards = response.data.value ?? [];
},
removeCard(id: number) {
const index = this.cards.findIndex((card) => card.id === id);
if (index !== -1) {
this.cards.splice(index, 1);
}
},
},
});