Mapa de erros 4.9, decisão do proprietário: os campos «Não documentado» das fichas (posto administrativo, localidade, coordenadas, polígono, data da fonte) continuam a ser mostrados e o portal distingue omissão de falta de informação. Cada campo vazio passa a dizer o seu estado: «Não documentado — por verificar na fonte», «Não consta da fonte» ou «Consta da fonte; em carregamento no portal». O estado é decidido por uma pessoa, nunca pelo portal: a nova página de gestão «Lacunas nas fichas» (/management/lacunas) lista os campos vazios das fichas publicadas, filtra por estado e regista a verificação com nota e evento de auditoria. Só se pode registar um campo que esteja de facto vazio nessa localização. Nova tabela information_gaps (migração). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
155 lines
5.4 KiB
TypeScript
155 lines
5.4 KiB
TypeScript
import { Link, router } from '@inertiajs/react';
|
|
import { useState } from 'react';
|
|
import { Management, button, control } from './shared';
|
|
import { api } from '@/pages/investment/shared';
|
|
|
|
type Item = {
|
|
dossier_id: string;
|
|
dossier: string;
|
|
location_id: string;
|
|
location: string;
|
|
field: string;
|
|
field_label: string;
|
|
status: string;
|
|
source_reference: string | null;
|
|
};
|
|
|
|
/** Mapa de erros 4.9: each empty field of a published record is checked against its source by a person. */
|
|
export default function InformationGaps({
|
|
items,
|
|
status,
|
|
statuses,
|
|
installed,
|
|
}: {
|
|
items: Item[];
|
|
status: string;
|
|
statuses: Record<string, string>;
|
|
installed: boolean;
|
|
}) {
|
|
return (
|
|
<Management title="Lacunas de informação nas fichas">
|
|
<p>
|
|
Cada campo vazio das fichas publicadas é mostrado ao investidor
|
|
com o estado indicado aqui. Compare com o documento de origem e
|
|
indique se a informação não consta da fonte ou se consta e falta
|
|
carregá-la no portal. O portal não decide isto sozinho.
|
|
</p>
|
|
{!installed && (
|
|
<p role="status">
|
|
O registo de lacunas ainda não está instalado neste ambiente
|
|
(migração por executar).
|
|
</p>
|
|
)}
|
|
<nav className="my-3 flex flex-wrap gap-3" aria-label="Estado">
|
|
{[...Object.entries(statuses), ['all', 'Todas']].map(
|
|
([key, label]) => (
|
|
<Link
|
|
key={key}
|
|
className={
|
|
key === status ? 'font-bold' : 'underline'
|
|
}
|
|
href={`/management/lacunas?status=${key}`}
|
|
>
|
|
{label}
|
|
</Link>
|
|
),
|
|
)}
|
|
</nav>
|
|
{items.length === 0 ? (
|
|
<p>Sem lacunas neste estado.</p>
|
|
) : (
|
|
<ul className="space-y-3">
|
|
{items.map((item) => (
|
|
<GapRow
|
|
key={`${item.dossier_id}:${item.location_id}:${item.field}`}
|
|
item={item}
|
|
statuses={statuses}
|
|
/>
|
|
))}
|
|
</ul>
|
|
)}
|
|
</Management>
|
|
);
|
|
}
|
|
|
|
function GapRow({
|
|
item,
|
|
statuses,
|
|
}: {
|
|
item: Item;
|
|
statuses: Record<string, string>;
|
|
}) {
|
|
const [value, setValue] = useState(item.status);
|
|
const [note, setNote] = useState('');
|
|
const [busy, setBusy] = useState(false);
|
|
const [error, setError] = useState('');
|
|
return (
|
|
<li className="rounded border p-3">
|
|
<p>
|
|
<Link
|
|
className="font-semibold underline"
|
|
href={`/carteira/${item.dossier_id}`}
|
|
>
|
|
{item.dossier}
|
|
</Link>{' '}
|
|
· {item.location} · <strong>{item.field_label}</strong>
|
|
</p>
|
|
<div className="mt-2 flex flex-wrap items-end gap-2">
|
|
<label className="grid gap-1 text-sm">
|
|
Estado
|
|
<select
|
|
className={control}
|
|
value={value}
|
|
onChange={(e) => setValue(e.target.value)}
|
|
>
|
|
{Object.entries(statuses).map(([key, label]) => (
|
|
<option key={key} value={key}>
|
|
{label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
<label className="grid min-w-64 flex-1 gap-1 text-sm">
|
|
Nota (o que foi consultado)
|
|
<input
|
|
className={control}
|
|
value={note}
|
|
maxLength={2000}
|
|
onChange={(e) => setNote(e.target.value)}
|
|
/>
|
|
</label>
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={busy || value === item.status}
|
|
onClick={async () => {
|
|
setBusy(true);
|
|
setError('');
|
|
try {
|
|
await api('/management/lacunas', {
|
|
dossier_id: item.dossier_id,
|
|
location_id: item.location_id,
|
|
field: item.field,
|
|
status: value,
|
|
note,
|
|
});
|
|
router.reload();
|
|
} catch (cause) {
|
|
setError(
|
|
cause instanceof Error
|
|
? cause.message
|
|
: 'Não foi possível guardar.',
|
|
);
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}}
|
|
>
|
|
{busy ? 'A guardar…' : 'Guardar'}
|
|
</button>
|
|
</div>
|
|
{error && <p role="alert">{error}</p>}
|
|
</li>
|
|
);
|
|
}
|