import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Calendar, Tag } from 'lucide-react';
import type { TimelineSubmissionData } from '@/types/timeline';

interface TimelineEventPreviewProps {
  data: TimelineSubmissionData;
}

export function TimelineEventPreview({ data }: TimelineEventPreviewProps) {
  const formatEventType = (type: string) => {
    return type.replace(/_/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase());
  };

  return (
    <Card>
      <CardHeader>
        <CardTitle className="flex items-center gap-2">
          <Tag className="h-4 w-4" />
          Timeline Event: {data.title}
        </CardTitle>
      </CardHeader>
      <CardContent className="space-y-4">
        <div className="grid grid-cols-2 gap-4 text-sm">
          <div>
            <span className="font-medium">Event Type:</span>
            <p className="text-muted-foreground">
              {formatEventType(data.event_type)}
            </p>
          </div>
          <div>
            <span className="font-medium">Date:</span>
            <p className="text-muted-foreground flex items-center gap-1">
              <Calendar className="h-3 w-3" />
              {new Date(data.event_date).toLocaleDateString()} 
              ({data.event_date_precision})
            </p>
          </div>
        </div>

        {(data.from_value || data.to_value) && (
          <div className="flex items-center gap-2 text-sm">
            <span className="font-medium">Change:</span>
            <span className="text-muted-foreground">
              {data.from_value || '—'} → {data.to_value || '—'}
            </span>
          </div>
        )}

        {data.description && (
          <div>
            <span className="font-medium text-sm">Description:</span>
            <p className="text-sm text-muted-foreground mt-1">
              {data.description}
            </p>
          </div>
        )}
      </CardContent>
    </Card>
  );
}
