import { Link } from '@inertiajs/react'; import AgreementInstrument from '@/components/partnership-agreement-instrument'; import { Frame, labels } from './shared'; type Availability = | 'available' | 'not_recorded' | 'scope_unknown' | 'restricted' | 'malformed'; type Snapshot = { availability: Availability; version?: number; status?: string; instrument_availability?: Availability; instrument?: unknown; instrument_partnership_version?: number; instrument_interest_version?: number; }; type Entry = { version: number | null; restricted: boolean; action: string | null; actor_name: string | null; occurred_at: string | null; reason: string | null; confirmation_party: string | null; partnership_version: number | null; interest_version: number | null; previous: Snapshot; after: Snapshot; }; type Props = { room_id: number; entries: Entry[]; first_url: string; next_url: string | null; older_page: boolean; room_href: string; dashboard_href: string; }; const actions: Record = { record: 'Registo de instrumento', confirm: 'Confirmação de parte', start: 'Início do acompanhamento', complete: 'Conclusão', cancel: 'Cancelamento', renew: 'Renovação', }; const unavailable: Record = { not_recorded: 'Esta informação não ficou guardada no evento. Não foi preenchida com a versão actual.', scope_unknown: 'O âmbito deste registo antigo não ficou identificado; o conteúdo não está disponível para esta conta.', restricted: 'O registo pertence a uma representação à qual esta conta não tem acesso actual.', malformed: 'O instrumento guardado não tem uma estrutura reconhecida. O registo foi conservado.', }; function Version({ value, title }: { value: Snapshot; title: string }) { return (

{title}

{value.availability !== 'available' ? (

{unavailable[value.availability]}

) : ( <>

Versão da sala {value.version} ·{' '} {labels[value.status ?? ''] ?? value.status ?? 'Estado não registado'}

{value.instrument_availability !== 'available' ? (

{ unavailable[ value.instrument_availability ?? 'not_recorded' ] }

) : ( <>

Contexto do instrumento: proposta{' '} {value.instrument_partnership_version ?? 'não registada'}{' '} · candidatura{' '} {value.instrument_interest_version ?? 'não registada'} .

)} )}
); } export default function AgreementHistory(p: Props) { return (

Consulta das decisões e instrumentos guardados, do mais recente para o mais antigo. Os nomes de pessoas provêm do cadastro actual; as condições, motivos e confirmações são os que ficaram registados. Esta consulta não altera decisões nem certifica assinatura jurídica.

{!p.entries.length && (

Ainda não existem alterações do acordo guardadas para apresentar.

)} {p.entries.map((entry, index) => (
Versão {entry.version ?? 'não registada'} ·{' '} {entry.restricted ? 'Conteúdo reservado' : (actions[entry.action ?? ''] ?? 'Alteração registada')} {!entry.restricted && ( <>

{entry.actor_name ?? 'Autor não registado'}{' '} ·{' '} {entry.occurred_at ?? 'Data não registada'}

Contexto da decisão: proposta{' '} {entry.partnership_version ?? 'não registada'}{' '} · candidatura{' '} {entry.interest_version ?? 'não registada'}.

{entry.confirmation_party && (

Parte que confirmou:{' '} {entry.confirmation_party === 'proponent' ? 'Proponente' : 'Candidata'} .

)} {entry.reason !== null && (

Motivo: {entry.reason || 'Não indicado'}

)} )}
))} {p.next_url && ( Consultar versões anteriores )}
); }