247 lines
12 KiB
TypeScript
247 lines
12 KiB
TypeScript
export type QuantitativeMapContext = {
|
|
state: 'available' | 'unavailable' | 'not_included' | 'error';
|
|
records: {
|
|
id: string;
|
|
zone_id: string;
|
|
zone_name: string;
|
|
zone_version: number;
|
|
url: string;
|
|
theme: 'workforce' | 'economic_potential';
|
|
indicator: string;
|
|
label?: string | null;
|
|
description?: string | null;
|
|
value: string | null;
|
|
unit?: string | null;
|
|
period_start?: string | null;
|
|
period_end?: string | null;
|
|
scope?: string | null;
|
|
population?: string | null;
|
|
methodology?: string | null;
|
|
source_reference?: string | null;
|
|
source_date?: string | null;
|
|
knowledge: string;
|
|
missing_metadata: string[];
|
|
}[];
|
|
zones_consulted?: number;
|
|
zone_limit?: number;
|
|
record_limit?: number;
|
|
truncated: boolean;
|
|
};
|
|
const labels: Record<string, string> = {
|
|
employment: 'Emprego',
|
|
investment: 'Investimento',
|
|
production: 'Produção',
|
|
exports: 'Exportações',
|
|
local_procurement: 'Compras locais',
|
|
};
|
|
const metadataLabels: Record<string, string> = {
|
|
unit: 'unidade',
|
|
period_start: 'início do período',
|
|
period_end: 'fim do período',
|
|
scope: 'âmbito',
|
|
population: 'população/base',
|
|
methodology: 'metodologia',
|
|
source_reference: 'fonte',
|
|
source_date: 'data da fonte',
|
|
};
|
|
const text = (value?: string | null) => value?.trim() || 'Não indicado';
|
|
|
|
export default function InvestmentMapIndicators({
|
|
context,
|
|
theme,
|
|
}: {
|
|
context: QuantitativeMapContext | null;
|
|
theme: string;
|
|
}) {
|
|
if (!['all', 'workforce', 'economic_potential'].includes(theme))
|
|
return null;
|
|
const rows =
|
|
context?.records.filter(
|
|
(row) => theme === 'all' || row.theme === theme,
|
|
) ?? [];
|
|
return (
|
|
<section
|
|
className="space-y-2 rounded border p-3"
|
|
aria-label="Indicadores quantitativos do contexto territorial"
|
|
>
|
|
<h3 className="font-semibold">
|
|
Indicadores quantitativos do contexto territorial
|
|
</h3>
|
|
<p>
|
|
Observações públicas das zonas e parques devolvidos como
|
|
contexto territorial, independentes das evidências das
|
|
oportunidades. Emprego não mede trabalhadores disponíveis;
|
|
investimento, produção e exportações não constituem um índice de
|
|
potencial ou garantia de retorno. A natureza prevista ou
|
|
efectiva de cada valor depende da descrição da fonte, não é
|
|
determinada automaticamente.
|
|
</p>
|
|
{!context ? (
|
|
<p role="status">A carregar indicadores quantitativos…</p>
|
|
) : context.state === 'error' ? (
|
|
<p role="alert">
|
|
Não foi possível consultar os indicadores. Pode repetir a
|
|
consulta do mapa.
|
|
</p>
|
|
) : context.state === 'not_included' ? (
|
|
<p>
|
|
O conjunto de zonas não está incluído com estes filtros
|
|
específicos de oportunidades. Não foi feita uma medição
|
|
quantitativa neste âmbito.
|
|
</p>
|
|
) : context.state === 'unavailable' ? (
|
|
<p>
|
|
Observações quantitativas indisponíveis nesta versão do
|
|
cadastro; os restantes dados do mapa mantêm-se.
|
|
</p>
|
|
) : (
|
|
<>
|
|
<p role="status">
|
|
{rows.length}{' '}
|
|
{rows.length === 1 ? 'observação' : 'observações'} nesta
|
|
camada, em {context.zones_consulted}{' '}
|
|
{context.zones_consulted === 1
|
|
? 'ficha territorial consultada.'
|
|
: 'fichas territoriais consultadas.'}
|
|
A contagem não mede cobertura nacional.
|
|
</p>
|
|
{context.truncated && (
|
|
<p role="note">
|
|
Cobertura incompleta: consulta limitada a{' '}
|
|
{context.zone_limit} fichas e {context.record_limit}{' '}
|
|
observações. Refine a localização.
|
|
</p>
|
|
)}
|
|
{rows.length === 0 ? (
|
|
<p>
|
|
Sem observações públicas destes indicadores na
|
|
resposta. Valor desconhecido não equivale a zero.
|
|
</p>
|
|
) : (
|
|
<details>
|
|
<summary>
|
|
Consultar valores, unidades e fontes (
|
|
{rows.length})
|
|
</summary>
|
|
<div className="overflow-x-auto">
|
|
<table className="w-full text-left text-sm">
|
|
<caption>
|
|
Cada linha conserva o âmbito da fonte.
|
|
Sem somas, conversões de unidade ou
|
|
moeda, médias ou comparação automática
|
|
entre períodos e populações.
|
|
</caption>
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">
|
|
Ficha e indicador
|
|
</th>
|
|
<th scope="col">Valor e unidade</th>
|
|
<th scope="col">Período e base</th>
|
|
<th scope="col">
|
|
Fonte e metodologia
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{rows.map((row) => (
|
|
<tr
|
|
key={`${row.zone_id}:${row.id}`}
|
|
className="border-t align-top"
|
|
>
|
|
<th scope="row" className="p-2">
|
|
<a
|
|
className="underline"
|
|
href={row.url}
|
|
>
|
|
{row.zone_name}
|
|
</a>
|
|
<p>
|
|
{labels[
|
|
row.indicator
|
|
] ?? row.indicator}
|
|
: {text(row.label)}
|
|
</p>
|
|
<p>
|
|
{text(row.description)}
|
|
</p>
|
|
<p>
|
|
Versão pública{' '}
|
|
{row.zone_version}
|
|
</p>
|
|
</th>
|
|
<td className="p-2">
|
|
<p>
|
|
{row.value ??
|
|
'Por determinar'}{' '}
|
|
· {text(row.unit)}
|
|
</p>
|
|
<p>
|
|
{row.knowledge ===
|
|
'documented'
|
|
? 'Documentado na fonte'
|
|
: row.knowledge ===
|
|
'disputed'
|
|
? 'Em divergência'
|
|
: 'Desconhecido'}
|
|
</p>
|
|
</td>
|
|
<td className="p-2">
|
|
<p>
|
|
{text(row.period_start)}{' '}
|
|
a {text(row.period_end)}
|
|
</p>
|
|
<p>
|
|
Âmbito:{' '}
|
|
{text(row.scope)}
|
|
</p>
|
|
<p>
|
|
População/base:{' '}
|
|
{text(row.population)}
|
|
</p>
|
|
</td>
|
|
<td className="p-2">
|
|
<p>
|
|
Fonte:{' '}
|
|
{text(
|
|
row.source_reference,
|
|
)}{' '}
|
|
· Data:{' '}
|
|
{text(row.source_date)}
|
|
</p>
|
|
<p>
|
|
Metodologia:{' '}
|
|
{text(row.methodology)}
|
|
</p>
|
|
{row.missing_metadata
|
|
.length > 0 && (
|
|
<p role="note">
|
|
Informação em falta:{' '}
|
|
{row.missing_metadata
|
|
.map(
|
|
(key) =>
|
|
metadataLabels[
|
|
key
|
|
] ??
|
|
key,
|
|
)
|
|
.join(', ')}
|
|
. Não agregar ou
|
|
comparar como se
|
|
estivesse completa.
|
|
</p>
|
|
)}
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</details>
|
|
)}
|
|
</>
|
|
)}
|
|
</section>
|
|
);
|
|
}
|