import { Ellipsis } from "lucide-react"; import { testBoard } from "../../../shared/testBoard"; import Board from "../../components/Board"; import { Button } from "../../components/Button"; import { themes } from "../../themes"; import { DropdownMenuTrigger, DropdownMenu, DropdownMenuItem, DropdownMenuContent, } from "../../components/DropdownMenu"; import { cn } from "../../lib/utils"; import { useWSMutation, useWSQuery } from "../../hooks"; const Collection = () => { const { data: collection, refetch } = useWSQuery( "user.getOwnCollection", null, ); const mutateSelected = useWSMutation("user.selectCollectionEntry"); const mutateShuffle = useWSMutation("user.addCollectionEntryToShuffle"); return (

Collection

{themes.map((theme) => { const selected = collection?.entries.some( (e) => e.id === theme.id && e.selected, ); const owned = collection?.entries.some((e) => e.id === theme.id); const times = collection?.entries.filter((e) => e.id === theme.id).length || 0; if (!owned) return null; return (

{theme.name} {owned && ( {" "} (Owned{times > 1 && ` ${times}x`}) )}

{owned && ( { mutateSelected .mutateAsync({ id: theme.id }) .then(() => refetch()); }} > Select mutateShuffle .mutateAsync({ id: theme.id }) .then(() => refetch()) } > {" "} Add to shuffle )}
{}} restartGame={() => {}} onRightClick={() => {}} width={11 * 32} height={4 * 32} className={cn( selected && "outline-primary outline-4 rounded-md", )} />
); })}
); }; export default Collection;