import { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; import Layout from '../../components/Layout'; export default function CardDetail() { const router = useRouter(); const { id } = router.query; const user = { email: 'me@randallstillwell.com', role: 'user' }; const [card, setCard] = useState(null); const [loading, setLoading] = useState(true); const [activeTab, setActiveTab] = useState('details'); const [ownedQuantity, setOwnedQuantity] = useState(0); const [showQuantityModal, setShowQuantityModal] = useState(false); const [showCollectionModal, setShowCollectionModal] = useState(false); const [showDeckModal, setShowDeckModal] = useState(false); const [selectedCollection, setSelectedCollection] = useState(''); const [selectedDeck, setSelectedDeck] = useState(''); const [quantity, setQuantity] = useState(1); const [isFavorited, setIsFavorited] = useState(false); // Mock card data - in real app this would come from API const mockCards = { '1': { id: 1, name: "Black Lotus", game: "MTG", rarity: "mythic", rarityColor: "#FFD700", rarityGradient: "from-yellow-400 to-orange-500", set: "Alpha", value: 25000, image: "/api/placeholder/1", description: "The most iconic Magic card ever printed", type: "Artifact", condition: "Near Mint", artist: "Christopher Rush", cardNumber: "232", flavorText: "The most powerful artifact ever created.", manaCost: "{0}", power: null, toughness: null, text: "{T}, Sacrifice Black Lotus: Add three mana of any one color to your mana pool.", rulings: [ "Black Lotus is banned in all formats except Vintage.", "The card was printed in Alpha, Beta, and Unlimited editions.", "It's considered one of the Power Nine." ], priceHistory: [ { date: '2023-01-01', price: 22000 }, { date: '2023-04-01', price: 23500 }, { date: '2023-07-01', price: 24000 }, { date: '2023-10-01', price: 24500 }, { date: '2024-01-01', price: 25000 } ], purchaseLinks: [ { name: 'TCGPlayer', url: 'https://www.tcgplayer.com/search/magic/product?productName=black+lotus', icon: '🃏' }, { name: 'eBay', url: 'https://www.ebay.com/sch/i.html?_nkw=black+lotus+magic+alpha', icon: '🛒' }, { name: 'Card Kingdom', url: 'https://www.cardkingdom.com/catalog/search?search=black+lotus', icon: '👑' }, { name: 'Star City Games', url: 'https://starcitygames.com/search?searchQuery=black+lotus', icon: '⭐' } ] }, '2': { id: 2, name: "Charizard", game: "Pokemon", rarity: "holographic", rarityColor: "#FF6B6B", rarityGradient: "from-red-400 to-pink-500", set: "Base Set", value: 350, image: "/api/placeholder/2", description: "The classic holographic Charizard", type: "Fire", condition: "Lightly Played", artist: "Mitsuhiro Arita", cardNumber: "4/102", flavorText: "Spits fire that is hot enough to melt boulders.", manaCost: null, power: "100", toughness: null, text: "Fire Spin: 100 damage. Discard 2 Energy cards attached to Charizard in order to use this attack.", rulings: [ "This is the most valuable card from the original Base Set.", "The holographic version is significantly more valuable than the non-holo.", "First printed in 1999." ], priceHistory: [ { date: '2023-01-01', price: 300 }, { date: '2023-04-01', price: 320 }, { date: '2023-07-01', price: 330 }, { date: '2023-10-01', price: 340 }, { date: '2024-01-01', price: 350 } ], purchaseLinks: [ { name: 'TCGPlayer', url: 'https://www.tcgplayer.com/search/pokemon/product?productName=charizard+base+set', icon: '🃏' }, { name: 'eBay', url: 'https://www.ebay.com/sch/i.html?_nkw=charizard+base+set+holographic', icon: '🛒' }, { name: 'Pokemon Center', url: 'https://www.pokemoncenter.com/search?q=charizard', icon: '⚡' } ] }, '3': { id: 3, name: "Mickey Mouse", game: "Lorcana", rarity: "enchanted", rarityColor: "#A855F7", rarityGradient: "from-purple-400 to-indigo-500", set: "First Chapter", value: 45, image: "/api/placeholder/3", description: "Disney's iconic character in card form", type: "Character", condition: "Near Mint", artist: "Disney", cardNumber: "1/204", flavorText: "The most magical mouse of all.", manaCost: "2", power: "2", toughness: "2", text: "When this character enters play, you may draw a card.", rulings: [ "This is the first Disney card game featuring Mickey Mouse.", "The enchanted version has special foil treatment.", "Released in 2023." ], priceHistory: [ { date: '2023-08-01', price: 40 }, { date: '2023-10-01', price: 42 }, { date: '2023-12-01', price: 44 }, { date: '2024-01-01', price: 45 } ], purchaseLinks: [ { name: 'TCGPlayer', url: 'https://www.tcgplayer.com/search/lorcana/product?productName=mickey+mouse', icon: '🃏' }, { name: 'eBay', url: 'https://www.ebay.com/sch/i.html?_nkw=mickey+mouse+lorcana+enchanted', icon: '🛒' }, { name: 'Disney Store', url: 'https://www.shopdisney.com/search?searchQuery=lorcana', icon: '✨' } ] } }; // Mock collections and decks data const mockCollections = [ { id: 1, name: 'My MTG Collection', game: 'MTG' }, { id: 2, name: 'Pokemon Favorites', game: 'Pokemon' }, { id: 3, name: 'Lorcana Disney', game: 'Lorcana' }, { id: 4, name: 'Rare Cards', game: 'MTG' }, { id: 5, name: 'Holographic Collection', game: 'Pokemon' } ]; const mockDecks = [ { id: 1, name: 'MTG Control Deck', game: 'MTG' }, { id: 2, name: 'Pokemon Aggro', game: 'Pokemon' }, { id: 3, name: 'Lorcana Midrange', game: 'Lorcana' }, { id: 4, name: 'MTG Combo', game: 'MTG' }, { id: 5, name: 'Pokemon Stall', game: 'Pokemon' } ]; useEffect(() => { if (id && mockCards[id]) { setCard(mockCards[id]); setLoading(false); } else if (id) { // Card not found setLoading(false); } }, [id]); const getTCGGradient = (game) => { const gradients = { 'MTG': 'from-purple-600 via-purple-500 to-indigo-600', 'Pokemon': 'from-blue-600 via-blue-500 to-cyan-600', 'Lorcana': 'from-pink-600 via-pink-500 to-purple-600' }; return gradients[game] || 'from-gray-600 to-gray-700'; }; const getTCGIcon = (game) => { const icons = { 'MTG': '🔮', 'Pokemon': '⚡', 'Lorcana': '✨' }; return icons[game] || '🃏'; }; const formatCurrency = (amount) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(amount); }; const getRarityLabel = (rarity) => { const rarityMap = { 'common': 'Common', 'uncommon': 'Uncommon', 'rare': 'Rare', 'mythic': 'Mythic', 'holographic': 'Holographic', 'enchanted': 'Enchanted' }; return rarityMap[rarity] || rarity; }; if (loading) { return (
); } if (!card) { return (
🃏

Card Not Found

The card you're looking for doesn't exist.

); } return ( {/* Hero Section with Card Image and Basic Info */}
{/* Background Pattern */}
{/* Card Image */}
{getTCGIcon(card.game)}

{card.name}

{card.set}

{getRarityLabel(card.rarity)}
{/* Card Info */}

{card.name}

{card.description}

{/* Ownership Status and Actions */}
Ownership Status
{ownedQuantity > 0 && ( Owned ({ownedQuantity}) )}
{getTCGIcon(card.game)} {card.game} {getRarityLabel(card.rarity)}
{formatCurrency(card.value)}
{/* Quick Actions */}
{card.purchaseLinks.slice(0, 3).map((link, index) => ( {link.icon} {link.name} ))}
{/* Content Tabs */}
{['details', 'price-history', 'purchase'].map((tab) => ( ))}
{/* Tab Content */}
{activeTab === 'details' && (
{/* Card Metadata */}

Card Information

TCG {card.game}
Set {card.set}
Card Number {card.cardNumber}
Type {card.type}
Rarity {getRarityLabel(card.rarity)}
Artist {card.artist}
Condition {card.condition}
{card.manaCost && (
Cost to Play {card.manaCost}
)} {card.power && (
Power {card.power}
)} {card.toughness && (
Toughness {card.toughness}
)} {card.hp && (
HP {card.hp}
)} {card.form && (
Form {card.form}
)} {card.weakness && (
Weakness {card.weakness}
)} {card.retreat_cost && (
Retreat Cost {card.retreat_cost}
)} {card.current_price && (
Current Price {formatCurrency(card.current_price)}
)}
{/* Card Text and Rulings */}

Card Text

{card.flavorText && (

"{card.flavorText}"

)} {card.text && (

{card.text}

)}
{card.rulings && card.rulings.length > 0 && (

Rulings

    {card.rulings.map((ruling, index) => (
  • {ruling}
  • ))}
)}
)} {activeTab === 'price-history' && (

Price History

{/* Price Graph */}

Price Trend

{/* Graph Container */}
{card.priceHistory.map((entry, index) => { const maxPrice = Math.max(...card.priceHistory.map(p => p.price)); const minPrice = Math.min(...card.priceHistory.map(p => p.price)); const priceRange = maxPrice - minPrice; const height = priceRange > 0 ? ((entry.price - minPrice) / priceRange) * 100 : 50; return (
{/* Bar */}
{/* Price Label */}
{formatCurrency(entry.price)}
{new Date(entry.date).toLocaleDateString('en-US', { month: 'short', day: 'numeric' })}
); })}
{/* Grid Lines */}
{[0, 25, 50, 75, 100].map((line) => (
))}
{/* Price Statistics Cards */}
{/* Current Price */}
💰
Current Price
{formatCurrency(card.value)}
{/* Lowest Price */}
📉
Lowest Price
{formatCurrency(Math.min(...card.priceHistory.map(p => p.price)))}
{/* Highest Price */}
📈
Highest Price
{formatCurrency(Math.max(...card.priceHistory.map(p => p.price)))}
{/* Average Price */}
📊
Average Price
{formatCurrency(card.priceHistory.reduce((sum, p) => sum + p.price, 0) / card.priceHistory.length)}
{/* Price Change Indicator */}
Price Change
{(() => { const firstPrice = card.priceHistory[0].price; const lastPrice = card.priceHistory[card.priceHistory.length - 1].price; const change = lastPrice - firstPrice; const changePercent = ((change / firstPrice) * 100).toFixed(1); const isPositive = change >= 0; return ( <> {isPositive ? '+' : ''}{formatCurrency(change)} ({isPositive ? '+' : ''}{changePercent}%) {isPositive ? '📈' : '📉'} ); })()}
)} {activeTab === 'purchase' && (

Where to Buy

{card.purchaseLinks.map((link, index) => (
{link.icon}

{link.name}

View on {link.name}

))}
)}
{/* Quantity Modal */} {showQuantityModal && (

{ownedQuantity > 0 ? 'Update Quantity' : 'Mark as Owned'}

{quantity}
)} {/* Collection Modal */} {showCollectionModal && (

Add to Collection

)} {/* Deck Modal */} {showDeckModal && (

Add to Deck

)}
); }