import React, { useContext } from 'react'; import { CardContext } from '../../store/CardContext'; import PrintingRow from '../PrintingRow/PrintingRow'; const BADGE = { monster: { background: '#3a2000', color: '#d4820a' }, spell: { background: '#002820', color: '#10a06a' }, trap: { background: '#280020', color: '#c040a0' }, other: { background: '#202020', color: '#666' }, }; function typeBadge(type) { const t = type.toLowerCase(); if (t.includes('monster')) return BADGE.monster; if (t.includes('spell')) return BADGE.spell; if (t.includes('trap')) return BADGE.trap; return BADGE.other; } const PRINTING_COLS = '80px 1fr 150px 100px'; function CardRow({ card }) { const { expandedCardId, setExpandedCardId, ownedAmounts } = useContext(CardContext); const isExpanded = expandedCardId === card.id; const totalOwned = card.printings?.reduce((sum, p) => { const key = `${p.set_id}-${p.rarity_id}`; return sum + (ownedAmounts[card.id]?.[key] ?? p.amount_owned ?? 0); }, 0) ?? 0; return (