@@ -0,0 +1,212 @@
|
||||
import { Head, Link, router } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import { PageTitle, Panel, controlClass } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
type GeoRow = {
|
||||
id: string;
|
||||
source_row: number;
|
||||
name: string;
|
||||
codes: string[];
|
||||
issues: string[];
|
||||
};
|
||||
const base = '/administracao/divisao-administrativa';
|
||||
|
||||
export default function GeographyReview({
|
||||
records,
|
||||
total,
|
||||
filters,
|
||||
issues,
|
||||
manifest,
|
||||
}: {
|
||||
records: GeoRow[];
|
||||
total: number;
|
||||
filters: { search: string; issue: string; page: number };
|
||||
issues: Record<string, string>;
|
||||
manifest: {
|
||||
source_file: string;
|
||||
records: number;
|
||||
selectable: number;
|
||||
edition: string | null;
|
||||
};
|
||||
}) {
|
||||
const [search, setSearch] = useState(filters.search);
|
||||
const [issue, setIssue] = useState(filters.issue);
|
||||
const query = new URLSearchParams({
|
||||
search: filters.search,
|
||||
issue: filters.issue,
|
||||
});
|
||||
const pageLink = (page: number) => `${base}?${query}&page=${page}`;
|
||||
return (
|
||||
<>
|
||||
<Head title="Revisão da divisão administrativa" />
|
||||
<main className="mx-auto flex w-full max-w-7xl flex-col gap-6 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow="Parametrização"
|
||||
title="Divisão administrativa por rever"
|
||||
description="Consulta da fonte e dos registos que ainda não podem ser seleccionados nos cadastros."
|
||||
action={
|
||||
<Button asChild variant="outline">
|
||||
<Link href="/administracao/parametrizacao">
|
||||
Voltar à parametrização
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<Panel title="Fonte preservada">
|
||||
<p className="text-sm">
|
||||
{manifest.source_file} · Edição{' '}
|
||||
{manifest.edition ?? 'por confirmar'}.
|
||||
</p>
|
||||
<p className="mt-2 text-sm">
|
||||
{manifest.records.toLocaleString('pt-PT')} registos
|
||||
conservados;{' '}
|
||||
{manifest.selectable.toLocaleString('pt-PT')}{' '}
|
||||
disponíveis para selecção;{' '}
|
||||
{(
|
||||
manifest.records - manifest.selectable
|
||||
).toLocaleString('pt-PT')}{' '}
|
||||
por rever.
|
||||
</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
Esta consulta não corrige ou cria localidades. Um código
|
||||
pode ter vários diagnósticos. Os registos permanecem
|
||||
indisponíveis até existir uma fonte esclarecida. Pode
|
||||
usar um nível superior confirmado no cadastro.
|
||||
</p>
|
||||
</Panel>
|
||||
<Panel title="Pendências da cartografia">
|
||||
<form
|
||||
className="mb-5 flex flex-wrap items-end gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
router.get(
|
||||
base,
|
||||
{ search, issue },
|
||||
{ preserveState: true },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label className="space-y-2 text-sm">
|
||||
Designação ou ID da fonte
|
||||
<Input
|
||||
value={search}
|
||||
maxLength={120}
|
||||
onChange={(event) =>
|
||||
setSearch(event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="space-y-2 text-sm">
|
||||
Diagnóstico
|
||||
<select
|
||||
className={controlClass}
|
||||
value={issue}
|
||||
onChange={(event) =>
|
||||
setIssue(event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos os diagnósticos</option>
|
||||
{Object.entries(issues).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<Button>Pesquisar</Button>
|
||||
<Button asChild variant="outline">
|
||||
<a href={`${base}.csv?${query}`}>
|
||||
Exportar resultados CSV
|
||||
</a>
|
||||
</Button>
|
||||
</form>
|
||||
<p className="mb-4 text-sm">
|
||||
{total.toLocaleString('pt-PT')} resultados · Página{' '}
|
||||
{filters.page} de {Math.max(1, Math.ceil(total / 50))}
|
||||
</p>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead className="border-b">
|
||||
<tr>
|
||||
{[
|
||||
'Linha / ID da fonte',
|
||||
'Designação original',
|
||||
'Códigos por nível',
|
||||
'Diagnósticos',
|
||||
].map((label) => (
|
||||
<th className="p-3" key={label}>
|
||||
{label}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{records.map((record) => (
|
||||
<tr
|
||||
className="border-b align-top"
|
||||
key={record.id}
|
||||
>
|
||||
<td className="p-3">
|
||||
{record.source_row} / {record.id}
|
||||
</td>
|
||||
<td className="p-3">
|
||||
{record.name ||
|
||||
'(designação vazia na fonte)'}
|
||||
</td>
|
||||
<td className="p-3 font-mono whitespace-nowrap">
|
||||
{record.codes
|
||||
.map((code) => code || '—')
|
||||
.join(' / ')}
|
||||
</td>
|
||||
<td className="p-3">
|
||||
{record.issues
|
||||
.map((code) => issues[code])
|
||||
.join('; ')}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{records.length === 0 && (
|
||||
<p className="py-5 text-sm">
|
||||
Não existem pendências para estes filtros.
|
||||
</p>
|
||||
)}
|
||||
<p className="mt-3 text-xs text-muted-foreground">
|
||||
Ordem dos códigos: província, distrito, posto
|
||||
administrativo, localidade, bairro urbano e
|
||||
aldeia/quarteirão. O CSV exporta todos os resultados
|
||||
filtrados; ao abrir numa folha de cálculo, importe os
|
||||
códigos como texto para conservar zeros iniciais.
|
||||
</p>
|
||||
<div className="mt-5 flex gap-3">
|
||||
{filters.page > 1 && (
|
||||
<Button asChild variant="outline">
|
||||
<Link href={pageLink(filters.page - 1)}>
|
||||
Anterior
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
{filters.page * 50 < total && (
|
||||
<Button asChild variant="outline">
|
||||
<Link href={pageLink(filters.page + 1)}>
|
||||
Seguinte
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Panel>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
GeographyReview.layout = {
|
||||
breadcrumbs: [
|
||||
{ title: 'Parametrização', href: '/administracao/parametrizacao' },
|
||||
{ title: 'Divisão administrativa', href: base },
|
||||
],
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
import { CompanyAdministrativeLocation } from '@/components/administrative-location';
|
||||
import type { GeographyDescription } from '@/components/administrative-location';
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { AiPlanSettings } from '@/components/ai-plan-settings';
|
||||
import type { AiPlan } from '@/components/ai-plan-settings';
|
||||
@@ -166,6 +168,8 @@ function Assignment({
|
||||
}
|
||||
export default function Parameters({
|
||||
ready,
|
||||
geographyEnabled = false,
|
||||
geography = null,
|
||||
active,
|
||||
version,
|
||||
permissions,
|
||||
@@ -188,6 +192,8 @@ export default function Parameters({
|
||||
enabledWorkContexts = [],
|
||||
}: {
|
||||
ready: boolean;
|
||||
geographyEnabled?: boolean;
|
||||
geography?: GeographyDescription;
|
||||
comparisonPolicy: ComparisonPolicy;
|
||||
intelligencePolicy?: IntelligencePolicy;
|
||||
intelligenceReady?: boolean;
|
||||
@@ -257,6 +263,17 @@ export default function Parameters({
|
||||
return (
|
||||
<>
|
||||
<Head title="Parametrização da aplicação" />
|
||||
{geographyEnabled && (
|
||||
<div className="mx-auto w-full max-w-7xl p-5">
|
||||
<CompanyAdministrativeLocation geography={geography} />
|
||||
<Link
|
||||
className="mt-4 inline-block font-semibold underline"
|
||||
href="/administracao/divisao-administrativa"
|
||||
>
|
||||
Consultar inconsistências da divisão administrativa
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
<Link
|
||||
href="/administracao/candidaturas/formularios"
|
||||
className="m-5 inline-block font-semibold underline"
|
||||
|
||||
Reference in New Issue
Block a user