feat: display precise public labour and economic observations in map context
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,246 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import InvestmentMapIndicators, {
|
||||
type QuantitativeMapContext,
|
||||
} from './investment-map-indicators';
|
||||
import CatalogueInvestmentMap from './catalogue-investment-map';
|
||||
import type {
|
||||
InvestmentMapArea,
|
||||
@@ -51,12 +54,14 @@ export default function ThematicInvestmentMap({
|
||||
records,
|
||||
territoryId,
|
||||
truncated,
|
||||
quantitative = null,
|
||||
}: {
|
||||
points: InvestmentMapFeature[] | null;
|
||||
areas: InvestmentMapArea[];
|
||||
records: ThematicMapRecord[];
|
||||
territoryId?: string;
|
||||
truncated: boolean;
|
||||
quantitative?: QuantitativeMapContext | null;
|
||||
}) {
|
||||
const [theme, setTheme] = useState('all');
|
||||
useEffect(() => {
|
||||
@@ -130,8 +135,8 @@ export default function ThematicInvestmentMap({
|
||||
(proof) => proof.category === key,
|
||||
),
|
||||
).length,
|
||||
)}
|
||||
)
|
||||
)}{' '}
|
||||
de oportunidades)
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -140,7 +145,9 @@ export default function ThematicInvestmentMap({
|
||||
evidência pública seleccionada. Os marcadores localizam a
|
||||
oportunidade; não representam a posição exacta, capacidade
|
||||
ou disponibilidade do recurso ou da infra-estrutura. A
|
||||
pesquisa geral mantém os seus filtros e resultados.
|
||||
pesquisa geral mantém os seus filtros e resultados. As
|
||||
contagens desta secção são de oportunidades; os indicadores
|
||||
territoriais têm contagem própria.
|
||||
</p>
|
||||
<p>
|
||||
Mão-de-obra: a evidência pode descrever necessidades ou
|
||||
@@ -174,9 +181,9 @@ export default function ThematicInvestmentMap({
|
||||
</p>
|
||||
{selected.length === 0 && (
|
||||
<p>
|
||||
Sem evidência pública local para esta camada e
|
||||
estes filtros. Não foram criadas posições no
|
||||
mapa.
|
||||
Sem evidência pública local nas oportunidades
|
||||
desta camada e estes filtros. Não foram criadas
|
||||
posições no mapa.
|
||||
</p>
|
||||
)}
|
||||
{selected.length > 0 && (
|
||||
@@ -267,6 +274,7 @@ export default function ThematicInvestmentMap({
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
<InvestmentMapIndicators context={quantitative} theme={theme} />
|
||||
<CatalogueInvestmentMap
|
||||
points={visiblePoints}
|
||||
areas={visibleAreas}
|
||||
|
||||
Reference in New Issue
Block a user