diff --git a/src/components/DeckCard.tsx b/src/components/DeckCard.tsx index 9837cc4..cf8928e 100644 --- a/src/components/DeckCard.tsx +++ b/src/components/DeckCard.tsx @@ -22,55 +22,52 @@ export default function DeckCard({ deck, onEdit }: DeckCardProps) { return (
onEdit?.(deck.id)} > -
+ {/* Full Card Art */} +
{commander?.name -
-
- -
-
-

{deck.name}

- {validation.isValid ? ( -
- - Legal -
- ) : ( -
- - Issues + {/* Overlay for text readability */} +
+ + {/* Deck info overlay */} +
+
+

{deck.name}

+ {validation.isValid ? ( + + ) : ( + + )} +
+ +
+ {deck.format} + {deck.cards.reduce((acc, curr) => acc + curr.quantity, 0)} cards +
+ + {commander && ( +
+ Commander: {commander.name}
)} -
- -
- {deck.format} - {deck.cards.reduce((acc, curr) => acc + curr.quantity, 0)} cards -
- - {commander && ( -
- Commander: {commander.name} -
- )} - + +
); diff --git a/src/components/DeckList.tsx b/src/components/DeckList.tsx index 9845ab1..5d3ccbb 100644 --- a/src/components/DeckList.tsx +++ b/src/components/DeckList.tsx @@ -90,7 +90,7 @@ const DeckList = ({ onDeckEdit, onCreateDeck }: DeckListProps) => { } return ( -
+
{decks.map((deck) => ( ))} @@ -98,15 +98,15 @@ const DeckList = ({ onDeckEdit, onCreateDeck }: DeckListProps) => { {/* Create New Deck Card */} diff --git a/src/components/DeckManager.tsx b/src/components/DeckManager.tsx index a88c897..268db54 100644 --- a/src/components/DeckManager.tsx +++ b/src/components/DeckManager.tsx @@ -96,6 +96,7 @@ const suggestLandCountAndDistribution = ( }; export default function DeckManager({ initialDeck, onSave }: DeckManagerProps) { + const [currentDeckId, setCurrentDeckId] = useState(initialDeck?.id || null); const [searchQuery, setSearchQuery] = useState(''); const [searchResults, setSearchResults] = useState([]); const [selectedCards, setSelectedCards] = useState<{ @@ -310,8 +311,9 @@ export default function DeckManager({ initialDeck, onSave }: DeckManagerProps) { setIsSaving(true); try { + const deckId = currentDeckId || crypto.randomUUID(); const deckToSave: Deck = { - id: initialDeck?.id || crypto.randomUUID(), + id: deckId, name: deckName, format: deckFormat, cards: selectedCards, @@ -337,9 +339,14 @@ export default function DeckManager({ initialDeck, onSave }: DeckManagerProps) { if (deckError) throw deckError; + // Update current deck ID if this was a new deck + if (!currentDeckId) { + setCurrentDeckId(deckId); + } + // Delete existing cards if updating - if (initialDeck) { - await supabase.from('deck_cards').delete().eq('deck_id', initialDeck.id); + if (currentDeckId) { + await supabase.from('deck_cards').delete().eq('deck_id', currentDeckId); } // Save the deck cards @@ -495,30 +502,38 @@ export default function DeckManager({ initialDeck, onSave }: DeckManagerProps) {
{/* Card Search Section */}
-
-
- - setSearchQuery(e.target.value)} - className="w-full pl-10 pr-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white" - placeholder="Search for cards..." - /> -
+ {/* Mobile-First Search Bar */} + + + setSearchQuery(e.target.value)} + className="w-full pl-10 pr-24 py-3 bg-gray-800 border border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 text-white" + placeholder="Rechercher une carte..." + /> + {searchQuery && ( + + )} -
+ {/* Vertical Card List for Mobile */} +
{searchResults.map(card => { const currentFaceIndex = getCurrentFaceIndex(card.id); const isMultiFaced = isDoubleFaced(card); @@ -532,17 +547,18 @@ export default function DeckManager({ initialDeck, onSave }: DeckManagerProps) { return (
-
+ {/* Card Thumbnail */} +
{getCardImageUri(card, currentFaceIndex) ? ( {displayName} ) : ( - +
)} {isMultiFaced && ( )}
-
-
-

{displayName}

- {inCollection > 0 && ( - - - x{inCollection} - + + {/* Card Info */} +
+

{displayName}

+
+ {card.mana_cost && ( +
{card.mana_cost}
+ )} + {card.prices?.usd && ( +
${card.prices.usd}
)}
- {card.prices?.usd && ( -
${card.prices.usd}
+ {inCollection > 0 && ( +
+ + x{inCollection} in collection +
)} -
- - -
+ + {/* Add Button */} + + + {/* Add to Collection Button (hidden on mobile by default) */} +
); })}