/* eslint-disable @next/next/no-img-element -- External card image URLs; next/image migration is out of scope. */ import { useEffect, useState } from 'react'; import { formatProcessedDestination, VOCAB } from '../lib/collection-vocabulary.js'; export const CONDITION_OPTIONS = ['NM', 'LP', 'MP', 'HP', 'DMG']; export default function ScannedCardItem({ card, collections, decks, selected, onToggleSelect, onIncrement, onDecrement, onUpdateMetadata, onMarkOwned, onAddToCollection, onAddToDeck, onRemove, isAdding = false, }) { const [ownedQuantity, setOwnedQuantity] = useState(null); const resolvedOwnedQuantity = card.databaseId ? ownedQuantity : null; useEffect(() => { if (!card.databaseId) { return; } let cancelled = false; (async () => { try { const response = await fetch(`/api/cards/${card.databaseId}/ownership`, { headers: { Authorization: `Bearer ${localStorage.getItem('auth_token')}`, }, }); if (!response.ok) return; const data = await response.json(); if (!cancelled) { setOwnedQuantity(typeof data.quantity === 'number' ? data.quantity : 0); } } catch { if (!cancelled) setOwnedQuantity(null); } })(); return () => { cancelled = true; }; }, [card.databaseId]); return (