From 2ffa49b8f0e253decde0d4b725a535c70bb63421 Mon Sep 17 00:00:00 2001 From: matthieur Date: Thu, 6 Mar 2025 11:43:32 +0100 Subject: [PATCH] find issue import cards --- src/components/DeckCard.tsx | 6 ++++++ src/components/DeckList.tsx | 11 ++++++----- src/components/DeckManager.tsx | 9 +++++---- src/services/api.ts | 2 ++ src/utils/deckValidation.ts | 3 +-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/components/DeckCard.tsx b/src/components/DeckCard.tsx index ab0c7fc..1f18c8a 100644 --- a/src/components/DeckCard.tsx +++ b/src/components/DeckCard.tsx @@ -9,6 +9,12 @@ interface DeckCardProps { } export default function DeckCard({ deck, onEdit }: DeckCardProps) { + + if(deck.id === "410ed539-a8f4-4bc4-91f1-6c113b9b7e25"){ + console.log("deck", deck.name); + console.log("cardEntities", deck.cards); + } + const validation = validateDeck(deck); const commander = deck.format === 'commander' ? deck.cards.find(card => card.is_commander diff --git a/src/components/DeckList.tsx b/src/components/DeckList.tsx index f583f47..ec71656 100644 --- a/src/components/DeckList.tsx +++ b/src/components/DeckList.tsx @@ -27,10 +27,7 @@ const DeckList = ({ onDeckEdit }: DeckListProps) => { .select('*') .eq('deck_id', deck.id); - if(deck.id === "410ed539-a8f4-4bc4-91f1-6c113b9b7e25"){ - console.log("deck", deck.name); - console.log("cardEntities", cardEntities); - } + if (cardsError) { console.error(`Error fetching cards for deck ${deck.id}:`, cardsError); @@ -40,7 +37,11 @@ const DeckList = ({ onDeckEdit }: DeckListProps) => { const cardIds = cardEntities.map((entity) => entity.card_id); const uniqueCardIds = [...new Set(cardIds)]; - console.log("uniqueCardIds", uniqueCardIds); + if(deck.id === "410ed539-a8f4-4bc4-91f1-6c113b9b7e25"){ + console.log("uniqueCardIds", uniqueCardIds); + } + + try { const scryfallCards = await getCardsByIds(uniqueCardIds); diff --git a/src/components/DeckManager.tsx b/src/components/DeckManager.tsx index 1585144..cddc79d 100644 --- a/src/components/DeckManager.tsx +++ b/src/components/DeckManager.tsx @@ -110,10 +110,11 @@ export default function DeckManager({ initialDeck, onSave }: DeckManagerProps) { const [deckName, setDeckName] = useState(initialDeck?.name || ''); const [deckFormat, setDeckFormat] = useState(initialDeck?.format || 'standard'); const [commander, setCommander] = useState( - initialDeck?.cards.find(c => - c.card.type_line?.toLowerCase().includes('legendary creature') - )?.card || null + initialDeck?.cards.find(card => + card.is_commander + )?.card || null ); + const { user } = useAuth(); const [isImporting, setIsImporting] = useState(false); const [isSaving, setIsSaving] = useState(false); @@ -449,7 +450,7 @@ export default function DeckManager({ initialDeck, onSave }: DeckManagerProps) { {selectedCards .filter(c => - c.card.type_line?.toLowerCase().includes('legendary creature') + c.card.type_line?.toLowerCase().includes('legendary') ) .map(({ card }) => (