swipe game with overlay

This commit is contained in:
2025-07-13 16:29:02 +02:00
parent f74eb98414
commit 6a818e9da5
10 changed files with 122 additions and 26 deletions

View File

@@ -1,20 +1,35 @@
import { defineStore } from "pinia";
import type { Card } from "~/types/Card";
import type { Collection } from "~/types/Collection";
export const useCardStore = defineStore("cardStore", {
state: () => ({
collections: [] as string[],
collections: [] as Collection[],
cards: [] as Card[],
smashList: [] as Card[],
passList: [] as Card[],
}),
actions: {
async fetchCollections() {
const { data: collections } =
await useFetch<string[]>("/api/collections");
this.collections = collections.value ?? [];
const data = await $fetch<Collection[]>("/api/collections/", {
baseURL: useApiBase(),
});
this.collections = data ?? [];
},
async fetchCardsByCollection(collectionName: string) {
const response = useFetch<Card[]>(`/api/cards/${collectionName}`);
this.cards = response.data.value ?? [];
const data = await $fetch<Card[]>(
`/api/cards/?collection__name=${collectionName}`,
{
baseURL: useApiBase(),
},
);
this.cards =
data.map((card, index) => ({
...card,
id: index,
})) ?? [];
console.log(this.cards);
},
removeCard(id: number) {
const index = this.cards.findIndex((card) => card.id === id);