Compare commits
No commits in common. "697dc3f5ef1f91fc3d5ff31716a5a69133bfecb8" and "a84316f9e253da519969e6459d6dcc33c21b9dca" have entirely different histories.
697dc3f5ef
...
a84316f9e2
2 changed files with 11 additions and 24 deletions
|
|
@ -45,11 +45,6 @@ export function useScannerQueue({ user, sessionDestination, scanDefaults, deckMo
|
||||||
const addingInFlightRef = useRef(new Set());
|
const addingInFlightRef = useRef(new Set());
|
||||||
const [addingCardIds, setAddingCardIds] = useState(() => new Set());
|
const [addingCardIds, setAddingCardIds] = useState(() => new Set());
|
||||||
const cartPersistTimerRef = useRef(null);
|
const cartPersistTimerRef = useRef(null);
|
||||||
const scannedCardsRef = useRef(scannedCards);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
scannedCardsRef.current = scannedCards;
|
|
||||||
}, [scannedCards]);
|
|
||||||
|
|
||||||
const persistCart = (cards, selection) => {
|
const persistCart = (cards, selection) => {
|
||||||
saveScannerCart({
|
saveScannerCart({
|
||||||
|
|
@ -167,25 +162,22 @@ export function useScannerQueue({ user, sessionDestination, scanDefaults, deckMo
|
||||||
setUndoStack((prev) => prev.filter((u) => u.cardId !== cardId));
|
setUndoStack((prev) => prev.filter((u) => u.cardId !== cardId));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCardScanned = useCallback((cardData) => {
|
const handleCardScanned = (cardData) => {
|
||||||
setAutoRouteError(null);
|
setAutoRouteError(null);
|
||||||
|
|
||||||
const { cardEntry, scannedCards: nextQueue } = mergeScannedCardEntry(
|
const { cardEntry, scannedCards: nextQueue } = mergeScannedCardEntry(
|
||||||
scannedCardsRef.current,
|
scannedCards,
|
||||||
cardData,
|
cardData,
|
||||||
scanDefaults
|
scanDefaults
|
||||||
);
|
);
|
||||||
setScannedCards((prev) => {
|
setScannedCards(nextQueue);
|
||||||
const { cardEntry: ce, scannedCards: nq } = mergeScannedCardEntry(prev, cardData, scanDefaults);
|
setSelectedCards((prev) => {
|
||||||
setSelectedCards((ps) => {
|
const next = new Set([...prev, cardEntry.id]);
|
||||||
const n = new Set([...ps, ce.id]);
|
persistCart(nextQueue, next);
|
||||||
persistCart(nq, n);
|
return next;
|
||||||
return n;
|
|
||||||
});
|
|
||||||
return nq;
|
|
||||||
});
|
});
|
||||||
return cardEntry.id;
|
return cardEntry.id;
|
||||||
}, [scanDefaults]);
|
};
|
||||||
|
|
||||||
const incrementCardQuantity = (cardId) => {
|
const incrementCardQuantity = (cardId) => {
|
||||||
setScannedCards((prev) =>
|
setScannedCards((prev) =>
|
||||||
|
|
|
||||||
|
|
@ -437,16 +437,11 @@ export default function MyCards() {
|
||||||
|
|
||||||
{/* Cards Grid */}
|
{/* Cards Grid */}
|
||||||
<div className={`
|
<div className={`
|
||||||
${viewMode === 'grid'
|
${viewMode === 'grid'
|
||||||
? 'grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4'
|
? 'grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4'
|
||||||
: 'space-y-4'
|
: 'space-y-4'
|
||||||
}
|
}
|
||||||
`}>
|
`}>
|
||||||
{cards.length === 0 && !loading && (
|
|
||||||
<div className="col-span-full text-center py-12" style={{ color: 'var(--text-secondary)' }}>
|
|
||||||
<p>No cards loaded from /api/cards/owned (summary shows {collectionSummary?.totalCards ?? 'N/A'} via /api/user/stats).</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{cards.map((card) => (
|
{cards.map((card) => (
|
||||||
<CardItem
|
<CardItem
|
||||||
key={card.id}
|
key={card.id}
|
||||||
|
|
@ -489,7 +484,7 @@ export default function MyCards() {
|
||||||
|
|
||||||
{/* No Cards Found */}
|
{/* No Cards Found */}
|
||||||
{cards.length === 0 && !loading && (
|
{cards.length === 0 && !loading && (
|
||||||
<div className="text-center py-20" data-testid="my-cards-empty-state">
|
<div className="text-center py-20">
|
||||||
<div className="glass-panel w-16 h-16 mx-auto mb-4 rounded-2xl flex items-center justify-center">
|
<div className="glass-panel w-16 h-16 mx-auto mb-4 rounded-2xl flex items-center justify-center">
|
||||||
<svg className="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24" style={{ color: 'var(--text-secondary)' }}>
|
<svg className="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24" style={{ color: 'var(--text-secondary)' }}>
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue