"use client"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { formatCurrency, formatDate, cn } from "@/lib/utils"; interface Tournament { id: string; name: string; description: string | null; type: string; status: string; startDate: string; endDate: string | null; maxPlayers: number | null; entryFee: number | string; settings: { tournamentFormat?: string; category?: string | null; } | null; site: { id: string; name: string; }; _count: { inscriptions: number; matches: number; }; } interface TournamentCardProps { tournament: Tournament; onClick?: () => void; } const statusConfig: Record = { DRAFT: { label: "Borrador", className: "bg-gray-100 text-gray-700 border-gray-300", }, REGISTRATION_OPEN: { label: "Inscripciones Abiertas", className: "bg-green-100 text-green-700 border-green-300", }, REGISTRATION_CLOSED: { label: "Inscripciones Cerradas", className: "bg-yellow-100 text-yellow-700 border-yellow-300", }, IN_PROGRESS: { label: "En Progreso", className: "bg-blue-100 text-blue-700 border-blue-300", }, COMPLETED: { label: "Finalizado", className: "bg-purple-100 text-purple-700 border-purple-300", }, CANCELLED: { label: "Cancelado", className: "bg-red-100 text-red-700 border-red-300", }, }; const typeLabels: Record = { BRACKET: "Eliminacion Directa", AMERICANO: "Americano", MEXICANO: "Mexicano", ROUND_ROBIN: "Round Robin", LEAGUE: "Liga", }; export function TournamentCard({ tournament, onClick }: TournamentCardProps) { const status = statusConfig[tournament.status] || statusConfig.DRAFT; const typeLabel = typeLabels[tournament.type] || tournament.type; const category = tournament.settings?.category; const entryFee = typeof tournament.entryFee === 'string' ? parseFloat(tournament.entryFee) : tournament.entryFee; return (
{tournament.name} {status.label}
{tournament.description && (

{tournament.description}

)}
{/* Type and Category */}
{typeLabel} {category && ( {category} )}
{/* Date */}
{formatDate(tournament.startDate)} {tournament.endDate && ( <> - {formatDate(tournament.endDate)} )}
{/* Inscriptions and Price */}
{tournament._count.inscriptions} {tournament.maxPlayers && ` / ${tournament.maxPlayers}`} {" equipos"}
{entryFee > 0 ? formatCurrency(entryFee) : "Gratis"}
{/* Site name */}
{tournament.site.name}
); }