import { Link } from 'react-router-dom'; import { Card } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Clock, User } from 'lucide-react'; import { formatDistanceToNow } from 'date-fns'; interface RecentChangeCardProps { entityType: 'park' | 'ride' | 'company'; entityId: string; entityName: string; entitySlug: string; parkSlug?: string; imageUrl?: string | null; changeType: string; changedAt: string; changedByUsername?: string | null; changedByAvatar?: string | null; changeReason?: string | null; } const changeTypeColors = { created: 'bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/20', updated: 'bg-blue-500/10 text-blue-700 dark:text-blue-400 border-blue-500/20', deleted: 'bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/20', restored: 'bg-purple-500/10 text-purple-700 dark:text-purple-400 border-purple-500/20', archived: 'bg-muted text-muted-foreground border-muted', }; const entityTypeColors = { park: 'bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 border-emerald-500/20', ride: 'bg-orange-500/10 text-orange-700 dark:text-orange-400 border-orange-500/20', company: 'bg-indigo-500/10 text-indigo-700 dark:text-indigo-400 border-indigo-500/20', }; const formatEntityType = (type: string): string => { return type .split('_') .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(' '); }; const formatChangeType = (type: string): string => { return type .split('_') .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(' '); }; export function RecentChangeCard({ entityType, entityId, entityName, entitySlug, parkSlug, imageUrl, changeType, changedAt, changedByUsername, changedByAvatar, changeReason, }: RecentChangeCardProps) { const getEntityPath = () => { if (entityType === 'park') return `/parks/${entitySlug}`; if (entityType === 'ride') { // For rides, use park slug if available, otherwise fallback to global rides list if (parkSlug) { return `/parks/${parkSlug}/rides/${entitySlug}`; } return `/rides`; } // Company paths - link to the appropriate company page return '/'; }; return ( {imageUrl && (
{entityName}
)}
{formatEntityType(entityType)} {formatChangeType(changeType)}

{entityName}

{changeReason && (

{changeReason}

)}
{formatDistanceToNow(new Date(changedAt), { addSuffix: true })}
{changedByUsername && (
{changedByUsername}
)}
); }