'use client'; import { CircleX } from 'lucide-react'; import { useAppContext } from '@/app/AppContext'; import TarokkaDeck from '@/lib/TarokkaDeck'; import getURL from '@/tools/getURL'; import { Deck } from '@/types'; const tarokkaDeck = new TarokkaDeck(); type CardSelectProps = { className?: string; }; export default function CardSelect({ className = '' }: CardSelectProps) { const { gameData, select, selectCardIndex, setSelectCardIndex } = useAppContext(); const { cards: hand, settings } = gameData; const handIDs = hand.map(({ id }) => id); const selectDeck: Deck | null = selectCardIndex >= 0 ? hand[selectCardIndex].deck : null; const close = () => setSelectCardIndex(-1); const handleClose = (event: React.MouseEvent) => { if (event.target === event.currentTarget) { close(); } }; if (!selectDeck) return null; const cards = selectDeck === 'high' ? tarokkaDeck.getHigh() : tarokkaDeck.getLow(); return (
{cards .filter(({ id }) => !handIDs.includes(id)) .map((card) => (
select(card.id)} > {card.aria}
))}
); }