import { Badge } from '@/components/ui/badge'; import { FieldDiff, ImageDiff, LocationDiff } from './FieldComparison'; import { detectChanges } from '@/lib/submissionChangeDetection'; import type { SubmissionItemData } from '@/types/submissions'; import type { SubmissionItemWithDeps } from '@/lib/submissionItemsService'; import { Building2, Train, MapPin, Building, User, ImageIcon, Trash2, Edit, Plus } from 'lucide-react'; interface SubmissionChangesDisplayProps { item: SubmissionItemData | SubmissionItemWithDeps; view?: 'summary' | 'detailed'; showImages?: boolean; } export function SubmissionChangesDisplay({ item, view = 'summary', showImages = true }: SubmissionChangesDisplayProps) { const changes = detectChanges(item); // Get appropriate icon for entity type const getEntityIcon = () => { const iconClass = "h-4 w-4"; switch (item.item_type) { case 'park': return ; case 'ride': return ; case 'manufacturer': case 'operator': case 'property_owner': case 'designer': return ; case 'photo': return ; default: return ; } }; // Get action badge const getActionBadge = () => { switch (changes.action) { case 'create': return New; case 'edit': return Edit; case 'delete': return Delete; } }; if (view === 'summary') { return (
{getEntityIcon()} {changes.entityName} {getActionBadge()}
{changes.action === 'edit' && changes.totalChanges > 0 && (
{changes.fieldChanges.slice(0, 5).map((change, idx) => ( ))} {changes.imageChanges.map((change, idx) => ( ))} {changes.hasLocationChange && ( Location )} {changes.totalChanges > 5 && ( +{changes.totalChanges - 5} more )}
)} {changes.action === 'create' && (
New {item.item_type}
)} {changes.action === 'delete' && (
Marked for deletion
)}
); } // Detailed view return (
{getEntityIcon()}

{changes.entityName}

{getActionBadge()}
{changes.action === 'create' && (
Creating new {item.item_type}
)} {changes.action === 'delete' && (
This {item.item_type} will be deleted
)} {changes.action === 'edit' && changes.totalChanges > 0 && ( <> {changes.fieldChanges.length > 0 && (

Field Changes ({changes.fieldChanges.length})

{changes.fieldChanges.map((change, idx) => ( ))}
)} {showImages && changes.imageChanges.length > 0 && (

Image Changes

{changes.imageChanges.map((change, idx) => ( ))}
)} {changes.hasLocationChange && (

Location Change

)} )} {changes.action === 'edit' && changes.totalChanges === 0 && (
No changes detected
)}
); }