'use client'; import type { TicketActor, TicketDetail } from '@/types'; import { formatDate } from '@/utils/date'; import { TicketStatusBadge, } from '../../components/TicketStatusBadge'; function formatCreatedDate(value: string | null | undefined) { if (!value) return '-'; return new Intl.DateTimeFormat('en-IN', { dateStyle: 'medium' }).format( new Date(value), ); } function getInitials(person: TicketActor | null | undefined) { const source = person?.name || person?.email || '?'; return source .split(/[\s@._-]+/) .filter(Boolean) .slice(0, 2) .map((part) => part.charAt(0).toUpperCase()) .join(''); } function getPersonLabel(person: TicketActor | null | undefined) { return person?.name || person?.email || '-'; } function MetaLabel({ children }: { children: React.ReactNode }) { return (

{children}

); } function MetaValue({ children }: { children: React.ReactNode }) { return

{children}

; } function PersonMetaValue({ person, accentClassName = 'bg-primary/15 text-primary', }: { person: TicketActor | null | undefined; accentClassName?: string; }) { if (!person) { return -; } return (
{getInitials(person)}

{getPersonLabel(person)}

); } function OverviewField({ label, children, }: { label: string; children: React.ReactNode; }) { return (
{label} {children}
); } export function TicketOverviewCard({ ticket }: { ticket: TicketDetail }) { const detectionCount = ticket.ai_result?.detection_count; return (

Overview

{detectionCount != null ? `${detectionCount} Occurrences` : '-'} {ticket.chainage_id || '-'} {formatCreatedDate(ticket.timestamps.created_at)} {formatDate(ticket.worker?.assigned_at)}
{ticket.ai_result?.completed_at ? (
AI analysis completed {formatDate(ticket.ai_result.completed_at)}
) : null}
); }