import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Calendar, MapPin, ArrowRight, Building2 } from 'lucide-react'; import { format } from 'date-fns'; import { parseDateForDisplay } from '@/lib/dateUtils'; interface HistoricalEntityCardProps { type: 'park' | 'ride'; entity: { id: string; name: string; operated_from?: string; operated_until?: string; closure_reason?: string; removal_reason?: string; location?: { name: string; city?: string; country: string; }; successor?: { id: string; name: string; slug: string; }; relocated_to?: { id: string; name: string; slug: string; }; }; onViewDetails?: () => void; } export function HistoricalEntityCard({ type, entity, onViewDetails }: HistoricalEntityCardProps) { const reason = type === 'park' ? entity.closure_reason : entity.removal_reason; const hasSuccessor = type === 'park' ? !!entity.successor : !!entity.relocated_to; const successorInfo = type === 'park' ? entity.successor : entity.relocated_to; return (
{entity.name} Historical {entity.location?.city && `${entity.location.city}, `} {entity.location?.country || entity.location?.name}
{/* Operating Dates */}
Operated:
{/* ⚠️ Use parseDateForDisplay to prevent timezone shifts */} {entity.operated_from && format(parseDateForDisplay(entity.operated_from), 'MMM d, yyyy')} {' - '} {entity.operated_until && format(parseDateForDisplay(entity.operated_until), 'MMM d, yyyy')}
{/* Closure/Removal Reason */} {reason && (
{type === 'park' ? 'Closure Reason' : 'Removal Reason'}

{reason}

)} {/* Successor/Relocation Info */} {hasSuccessor && successorInfo && (
{type === 'park' ? 'Succeeded by' : 'Relocated to'}:
)} {/* View Details Button */} {onViewDetails && ( )}
); }