import { Link, useForm } from '@inertiajs/react'; import { Management, Field, button, control, states } from './shared'; type Interest = { id: number; reference: string; full_name: string; email: string; phone: string | null; investor_type: string; country: string; sector_interest: string; opportunity_reference: string | null; investment_range: string | null; message: string; status: string; existing_business_id: string | null; modality: string | null; assigned_to: number | null; next_action: string | null; next_action_due_at: string | null; consented_at: string | null; reviewed_at: string | null; reviewed_by: number | null; created_at: string; source_page: string | null; metadata?: { submission_id?: string; journey_id?: string; dossier_id?: string; role?: string; horizon?: string; }; }; function dateTime(value: string | null) { if (!value) return '—'; return new Intl.DateTimeFormat('pt-MZ', { dateStyle: 'medium', timeStyle: 'short', timeZone: 'Africa/Maputo', }).format(new Date(value)); } type Transition = { from_status: string | null; to_status: string; actor_id: number | null; note: string | null; created_at: string; }; type Assignee = { id: number; name: string }; type Consent = { purpose: string; policy_version: string | null; status: string; granted_at: string | null; withdrawn_at: string | null; }; export default function InterestDetail({ interest, history = [], assignees = [], consents = [], declaredOrigin, }: { interest: Interest; history?: Transition[]; assignees?: Assignee[]; consents?: Consent[]; declaredOrigin: { code: string | null; name: string }; }) { const form = useForm({ status: interest.status, note: '', next_action: interest.next_action ?? '', next_action_due_at: interest.next_action_due_at?.slice(0, 10) ?? '', assigned_to: interest.assigned_to?.toString() ?? '', }); const contactConsentForm = useForm({ reason: '' }); const sharingConsentForm = useForm({ reason: '' }); const rows: [string, string | number | null][] = [ ['Nome', interest.full_name], ['Email', interest.email], ['Telefone', interest.phone], ['Tipo de investidor', interest.investor_type], ['País', interest.country], ['Página de entrada registada', interest.source_page], [ 'Origem declarada da solicitação', declaredOrigin.code ? `${declaredOrigin.name} (${declaredOrigin.code})` : declaredOrigin.name, ], ['Sector', interest.sector_interest], ['Oportunidade', interest.opportunity_reference], ['Negócio publicado', interest.existing_business_id], ['Modalidade', interest.modality], ['Faixa de investimento', interest.investment_range], ['Recebido em (Maputo)', dateTime(interest.created_at)], ['Consentimento em (Maputo)', dateTime(interest.consented_at)], ['Revisto em (Maputo)', dateTime(interest.reviewed_at)], ['Revisto pelo utilizador', interest.reviewed_by], ]; return ( {interest.metadata?.submission_id && ( Consultar manifestação completa, necessidades e anexos privados )} {interest.metadata?.dossier_id && (

Contexto de investimento

Consultar corredor, cluster ou projecto de origem

Jornada: {interest.metadata.journey_id}

Papel: {interest.metadata.role} · Horizonte:{' '} {interest.metadata.horizon}

)} Encaminhar para o CRM
{rows.map(([label, value]) => (
{label}
{value ?? '—'}
))}

Mensagem

{interest.message}

Consentimentos e versões

{consents.map((consent, index) => (

{consent.purpose}: {consent.status}

Política {consent.policy_version ?? '—'} · concedido{' '} {dateTime(consent.granted_at)}

{consent.withdrawn_at && (

Revogado {dateTime(consent.withdrawn_at)}

)}
))} {consents.some( (consent) => consent.purpose === 'respond_to_interest' && consent.status === 'granted', ) && (
{ event.preventDefault(); contactConsentForm.patch( `/management/interests/${interest.id}/consent/contact`, ); }} >