/* eslint-disable @next/next/no-img-element -- External or generated image URLs; next/image migration is out of scope. */
import CollectionSelectionModal from './CollectionSelectionModal';
import CardDetailQuantityModal from './CardDetailQuantityModal';
import CardDetailDeckModal from './CardDetailDeckModal';
import { ManaCost, ColorIdentity, AdvancedManaCost } from './ManaSymbols';
import ManaSymbolSettings from './ManaSymbolSettings';
import { VOCAB, collectionDisplayName } from '../lib/collection-vocabulary.js';
export default function CardDetailView(props) {
const {
activeTab,
adminLoading,
card,
cardCollections,
cardDecks,
collections,
decks,
formatCurrency,
getParticleColor,
getParticleCount,
getRarityColor,
getRarityGradient,
getRarityLabel,
getTCGIcon,
handleAddToCollection,
handleAddToDeck,
handleOwnershipUpdate,
handleToggleFavorite,
id,
isAdmin,
isFavorited,
loading,
manaSymbolSettings,
ownedQuantity,
particleStyles,
quantity,
router,
selectedCollection,
selectedDeck,
setActiveTab,
setCard,
setCardCollections,
setCardDecks,
setCollections,
setDecks,
setIsFavorited,
setLoading,
setManaSymbolSettings,
setOwnedQuantity,
setQuantity,
setSelectedCollection,
setSelectedDeck,
setShowCollectionModal,
setShowDeckModal,
setShowQuantityModal,
showCollectionModal,
showDeckModal,
showInitialLoading,
showQuantityModal
} = props;
return (
<>
{/* Hero Section with Card Image and Basic Info */}
{/* Animated Particles Background */}
{getParticleCount(card.rarity) > 0 && (
{particleStyles.map((style, i) => (
))}
)}
{/* Background Pattern */}
{/* Card Image */}
{/* Rarity Glow Effect */}
{card.image_url ? (

) : (
{getTCGIcon(card.game)}
{card.name}
{card.set_name}
{getRarityLabel(card.rarity)}
)}
{/* Card Info */}
{card.name}
{card.oracle_text || card.card_type}
{/* Ownership Status and Actions */}
Ownership Status
{ownedQuantity > 0 && (
In {VOCAB.MY_COLLECTION} ({ownedQuantity})
)}
{getTCGIcon(card.game)}
{card.game}
{getRarityLabel(card.rarity)}
{formatCurrency(card.current_price || 0)}
{/* Admin Edit Button */}
{isAdmin && !adminLoading && (
)}
{/* Current Collections and Decks */}
{(cardCollections.length > 0 || cardDecks.length > 0) && (
Currently In:
{cardCollections.map(collection => (
📁
{collectionDisplayName(collection)}
))}
{cardDecks.map(deck => (
🎴
{deck.name}
))}
)}
{/* Content Tabs */}
{['details', 'price-history', 'purchase'].map((tab) => (
))}
{/* Tab Content */}
{activeTab === 'details' && (
{/* Card Metadata */}
Card Information
TCG
{card.game}
Set
{card.set_name}
Card Number
{card.card_number}
Type
{card.card_type}
Rarity
{getRarityLabel(card.rarity)}
{card.mana_cost && (
Cost to Play
)}
{card.power && (
Power
{card.power}
)}
{card.toughness && (
Toughness
{card.toughness}
)}
{card.current_price && (
Current Price
{formatCurrency(card.current_price)}
)}
{/* Card Text */}
Card Text
{card.oracle_text && (
)}
)}
{activeTab === 'price-history' && (
Price History
{/* Price Graph Placeholder */}
Price Trend
Price history data will be available soon
{/* Price Statistics Cards */}
{/* Current Price */}
💰
Current Price
{formatCurrency(card.current_price || 0)}
)}
{activeTab === 'purchase' && (
)}
setShowQuantityModal(false)}
/>
{/* Collection Selection Modal */}
setShowCollectionModal(false)}
cards={card ? [card] : []}
onAddToCollections={(results, selectedCollectionIds, cards) => {
const successCount = results.filter(r => r.success).length;
if (successCount > 0) {
// Refresh card collections
const fetchCardCollections = async () => {
try {
const token = localStorage.getItem('auth_token');
const response = await fetch(`/api/cards/${id}/collections`, {
headers: { 'Authorization': `Bearer ${token}` }
});
if (response.ok) {
const data = await response.json();
setCardCollections(data);
}
} catch (error) {
console.error('Error refreshing card collections:', error);
}
};
fetchCardCollections();
}
}}
/>
{
setShowDeckModal(false);
setSelectedDeck('');
}}
/>
>
);
}