fix commander on DeckCard component
This commit is contained in:
@@ -11,7 +11,7 @@ interface DeckCardProps {
|
|||||||
export default function DeckCard({ deck, onEdit }: DeckCardProps) {
|
export default function DeckCard({ deck, onEdit }: DeckCardProps) {
|
||||||
const validation = validateDeck(deck);
|
const validation = validateDeck(deck);
|
||||||
const commander = deck.format === 'commander' ? deck.cards.find(card =>
|
const commander = deck.format === 'commander' ? deck.cards.find(card =>
|
||||||
card.card.type_line?.toLowerCase().includes('legendary creature')
|
card.is_commander
|
||||||
)?.card : null;
|
)?.card : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ const DeckList = ({ onDeckEdit }: DeckListProps) => {
|
|||||||
.select('*')
|
.select('*')
|
||||||
.eq('deck_id', deck.id);
|
.eq('deck_id', deck.id);
|
||||||
|
|
||||||
|
if(deck.id === "410ed539-a8f4-4bc4-91f1-6c113b9b7e25"){
|
||||||
|
console.log("deck", deck.name);
|
||||||
|
console.log("cardEntities", cardEntities);
|
||||||
|
}
|
||||||
|
|
||||||
if (cardsError) {
|
if (cardsError) {
|
||||||
console.error(`Error fetching cards for deck ${deck.id}:`, cardsError);
|
console.error(`Error fetching cards for deck ${deck.id}:`, cardsError);
|
||||||
return { ...deck, cards: [] };
|
return { ...deck, cards: [] };
|
||||||
@@ -35,6 +40,8 @@ const DeckList = ({ onDeckEdit }: DeckListProps) => {
|
|||||||
const cardIds = cardEntities.map((entity) => entity.card_id);
|
const cardIds = cardEntities.map((entity) => entity.card_id);
|
||||||
const uniqueCardIds = [...new Set(cardIds)];
|
const uniqueCardIds = [...new Set(cardIds)];
|
||||||
|
|
||||||
|
console.log("uniqueCardIds", uniqueCardIds);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const scryfallCards = await getCardsByIds(uniqueCardIds);
|
const scryfallCards = await getCardsByIds(uniqueCardIds);
|
||||||
|
|
||||||
@@ -48,6 +55,7 @@ const DeckList = ({ onDeckEdit }: DeckListProps) => {
|
|||||||
return {
|
return {
|
||||||
card,
|
card,
|
||||||
quantity: entity.quantity,
|
quantity: entity.quantity,
|
||||||
|
is_commander: entity.is_commander,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export interface Deck {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
format: string;
|
format: string;
|
||||||
cards: { card: Card; quantity: number }[];
|
cards: { card: Card; quantity: number, is_commander: boolean }[];
|
||||||
userId: string;
|
userId: string;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
|
|||||||
Reference in New Issue
Block a user