Files
Investidor-V2/resources/js/pages/profiles/technical-incident.tsx
T

99 lines
4.0 KiB
TypeScript

import { Link } from '@inertiajs/react';
import TechnicalIncidentHandling from '@/components/technical-incident-handling';
import TechnicalIncidentNotice from '@/components/technical-incident-notice';
import {
handlingLabels,
commandLabels,
incidentOperationLabel,
incidentErrorLabel,
} from '@/lib/technical-incident-labels';
import type { HandlingProps, Command } from '@/lib/technical-incident-handling';
import { Management, Pagination, type Paginated } from '../management/shared';
export default function TechnicalIncident(
props: HandlingProps & {
backUrl: string;
notice?: { unread: boolean };
history: Paginated<{
id: string;
version: number | null;
action: Command | null;
status: string | null;
actor: string | null;
occurred_at: string;
note: string | null;
note_available: boolean;
}>;
},
) {
const row = props.incident;
return (
<Management title="Tratamento de incidente técnico">
<Link className="underline" href={props.backUrl}>
Voltar à fila de suporte
</Link>
<section className="space-y-2 rounded border p-4">
<h2 className="font-semibold">
{incidentOperationLabel(row.operation)} · versão observada{' '}
{row.observed_version}
</h2>
<p className="break-all">Referência: {row.reference}</p>
<p>{row.occurred_at}</p>
<p>{incidentErrorLabel(row.error_code)}</p>
<p>Estado técnico: {handlingLabels[row.handling.status]}</p>
<p>
Responsável actual:{' '}
{row.handling.assignee_name || 'Por assumir'}
</p>
</section>
{props.notice && (
<TechnicalIncidentNotice
key={`notice:${props.actorId}:${row.reference}`}
actorId={props.actorId}
reference={row.reference}
unread={props.notice.unread}
/>
)}
<TechnicalIncidentHandling
key={`${props.actorId}:${row.reference}`}
{...props}
/>
<section className="space-y-3" aria-label="Histórico do tratamento">
<h2 className="text-xl font-semibold">
Histórico do tratamento
</h2>
{!props.history.data.length && <p>Sem tratamento registado.</p>}
{props.history.data.map((entry) => (
<article
className="space-y-2 rounded border p-4"
key={entry.id}
>
<h3 className="font-semibold">
Versão {entry.version ?? 'não identificada'} ·{' '}
{entry.action
? commandLabels[entry.action]
: 'Registo anterior'}
</h3>
<p>
{entry.actor || 'Autor não identificado'} ·{' '}
{entry.occurred_at}
</p>
<p>
Estado:{' '}
{entry.status
? handlingLabels[entry.status] ||
'Não identificado'
: 'Não identificado'}
</p>
<p className="break-words whitespace-pre-wrap">
{entry.note_available
? entry.note
: 'Nota indisponível para leitura; original preservado.'}
</p>
</article>
))}
<Pagination page={props.history} />
</section>
</Management>
);
}