200 lines
8.0 KiB
TypeScript
200 lines
8.0 KiB
TypeScript
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<string, string> = {
|
|
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<string, string> = {
|
|
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 (
|
|
<section className="space-y-3 rounded border p-4">
|
|
<h3 className="font-bold">{title}</h3>
|
|
{value.availability !== 'available' ? (
|
|
<p>{unavailable[value.availability]}</p>
|
|
) : (
|
|
<>
|
|
<p>
|
|
Versão da sala {value.version} ·{' '}
|
|
{labels[value.status ?? ''] ??
|
|
value.status ??
|
|
'Estado não registado'}
|
|
</p>
|
|
{value.instrument_availability !== 'available' ? (
|
|
<p>
|
|
{
|
|
unavailable[
|
|
value.instrument_availability ??
|
|
'not_recorded'
|
|
]
|
|
}
|
|
</p>
|
|
) : (
|
|
<>
|
|
<p>
|
|
Contexto do instrumento: proposta{' '}
|
|
{value.instrument_partnership_version ??
|
|
'não registada'}{' '}
|
|
· candidatura{' '}
|
|
{value.instrument_interest_version ??
|
|
'não registada'}
|
|
.
|
|
</p>
|
|
<AgreementInstrument value={value.instrument} />
|
|
</>
|
|
)}
|
|
</>
|
|
)}
|
|
</section>
|
|
);
|
|
}
|
|
export default function AgreementHistory(p: Props) {
|
|
return (
|
|
<Frame title={`Histórico do acordo · Sala ${p.room_id}`}>
|
|
<div className="space-y-6 break-words">
|
|
<nav
|
|
aria-label="Navegação do histórico"
|
|
className="flex flex-wrap gap-4"
|
|
>
|
|
<Link className="underline" href={p.room_href}>
|
|
Voltar à sala
|
|
</Link>
|
|
<Link className="underline" href={p.dashboard_href}>
|
|
Painel de parcerias
|
|
</Link>
|
|
{p.older_page && (
|
|
<Link className="underline" href={p.first_url}>
|
|
Versões mais recentes
|
|
</Link>
|
|
)}
|
|
</nav>
|
|
<p>
|
|
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>
|
|
{!p.entries.length && (
|
|
<p>
|
|
Ainda não existem alterações do acordo guardadas para
|
|
apresentar.
|
|
</p>
|
|
)}
|
|
{p.entries.map((entry, index) => (
|
|
<details
|
|
key={index}
|
|
open={index === 0}
|
|
className="space-y-4 rounded border p-4"
|
|
>
|
|
<summary className="cursor-pointer font-bold">
|
|
Versão {entry.version ?? 'não registada'} ·{' '}
|
|
{entry.restricted
|
|
? 'Conteúdo reservado'
|
|
: (actions[entry.action ?? ''] ??
|
|
'Alteração registada')}
|
|
</summary>
|
|
{!entry.restricted && (
|
|
<>
|
|
<p>
|
|
{entry.actor_name ?? 'Autor não registado'}{' '}
|
|
·{' '}
|
|
{entry.occurred_at ?? 'Data não registada'}
|
|
</p>
|
|
<p>
|
|
Contexto da decisão: proposta{' '}
|
|
{entry.partnership_version ??
|
|
'não registada'}{' '}
|
|
· candidatura{' '}
|
|
{entry.interest_version ?? 'não registada'}.
|
|
</p>
|
|
{entry.confirmation_party && (
|
|
<p>
|
|
Parte que confirmou:{' '}
|
|
{entry.confirmation_party ===
|
|
'proponent'
|
|
? 'Proponente'
|
|
: 'Candidata'}
|
|
.
|
|
</p>
|
|
)}
|
|
{entry.reason !== null && (
|
|
<p className="whitespace-pre-wrap">
|
|
Motivo: {entry.reason || 'Não indicado'}
|
|
</p>
|
|
)}
|
|
</>
|
|
)}
|
|
<div className="grid gap-4 lg:grid-cols-2">
|
|
<Version
|
|
title="Antes da alteração"
|
|
value={entry.previous}
|
|
/>
|
|
<Version
|
|
title="Após a alteração"
|
|
value={entry.after}
|
|
/>
|
|
</div>
|
|
</details>
|
|
))}
|
|
{p.next_url && (
|
|
<Link className="inline-block underline" href={p.next_url}>
|
|
Consultar versões anteriores
|
|
</Link>
|
|
)}
|
|
</div>
|
|
</Frame>
|
|
);
|
|
}
|