fix commander on DeckCard component

This commit is contained in:
matthieur
2025-03-06 10:14:43 +01:00
parent 904403508f
commit 217f1b662f
3 changed files with 10 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ interface DeckCardProps {
export default function DeckCard({ deck, onEdit }: DeckCardProps) {
const validation = validateDeck(deck);
const commander = deck.format === 'commander' ? deck.cards.find(card =>
card.card.type_line?.toLowerCase().includes('legendary creature')
card.is_commander
)?.card : null;
return (

View File

@@ -27,6 +27,11 @@ 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);
return { ...deck, cards: [] };
@@ -35,6 +40,8 @@ const DeckList = ({ onDeckEdit }: DeckListProps) => {
const cardIds = cardEntities.map((entity) => entity.card_id);
const uniqueCardIds = [...new Set(cardIds)];
console.log("uniqueCardIds", uniqueCardIds);
try {
const scryfallCards = await getCardsByIds(uniqueCardIds);
@@ -48,6 +55,7 @@ const DeckList = ({ onDeckEdit }: DeckListProps) => {
return {
card,
quantity: entity.quantity,
is_commander: entity.is_commander,
};
});

View File

@@ -22,7 +22,7 @@ export interface Deck {
id: string;
name: string;
format: string;
cards: { card: Card; quantity: number }[];
cards: { card: Card; quantity: number, is_commander: boolean }[];
userId: string;
createdAt: Date;
updatedAt: Date;