Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import EvidenceDetails from './evidence-details';
|
||||
import DemographicReadingSummary from './demographic-reading-summary';
|
||||
|
||||
export type DemographicAnalysis = {
|
||||
sector?: string;
|
||||
state: string;
|
||||
start_year: number;
|
||||
end_year: number;
|
||||
@@ -59,6 +63,24 @@ const indicators: Record<string, string> = {
|
||||
fertility_rate: 'Fecundidade',
|
||||
population_growth_rate: 'Crescimento populacional',
|
||||
};
|
||||
type Value =
|
||||
DemographicAnalysis['territories'][number]['series'][number]['values'][number];
|
||||
export function demographicHighlights(values: Value[]): Value[] {
|
||||
const totals = values.filter(
|
||||
(v) => v.age_group === 'all' && v.residence === 'all',
|
||||
);
|
||||
// Never add age groups, choose between sources or mix observed/projected values.
|
||||
return totals.filter(
|
||||
(v) =>
|
||||
!totals.some(
|
||||
(other) =>
|
||||
other.indicator === v.indicator &&
|
||||
other.unit === v.unit &&
|
||||
other.data_kind === v.data_kind &&
|
||||
other.year > v.year,
|
||||
),
|
||||
);
|
||||
}
|
||||
export default function DemographicEvidence({
|
||||
evidence,
|
||||
}: {
|
||||
@@ -66,8 +88,17 @@ export default function DemographicEvidence({
|
||||
}) {
|
||||
return (
|
||||
<section className="space-y-4" aria-label="Evidência demográfica">
|
||||
<p className="text-sm">
|
||||
Os indicadores demográficos não demonstram procura ou
|
||||
rentabilidade. Cruze-os com oferta existente, acessos, custos e
|
||||
procura documentada.
|
||||
</p>
|
||||
{evidence.state !== 'available' && (
|
||||
<p>Sem séries demográficas aprovadas para esta selecção.</p>
|
||||
<p>
|
||||
Sem indicadores disponíveis para esta selecção. Isto não
|
||||
significa população inexistente nem ausência de potencial
|
||||
económico.
|
||||
</p>
|
||||
)}
|
||||
{evidence.territories.map((t) => (
|
||||
<article
|
||||
@@ -85,101 +116,175 @@ export default function DemographicEvidence({
|
||||
<p>Sem dados no período escolhido.</p>
|
||||
)}
|
||||
{t.series.map((s) => (
|
||||
<details key={s.import_id} open={t.series.length === 1}>
|
||||
<summary>
|
||||
{s.source} · {s.version} · {s.file_name}
|
||||
</summary>
|
||||
<p className="text-xs break-all">
|
||||
SHA256: {s.sha256}
|
||||
</p>
|
||||
<section key={s.import_id} className="space-y-3">
|
||||
<h3 className="font-semibold">{s.source}</h3>
|
||||
<DemographicReadingSummary
|
||||
series={s}
|
||||
evidence={evidence}
|
||||
/>
|
||||
{demographicHighlights(s.values).some(
|
||||
(v) => v.indicator !== 'population',
|
||||
) && (
|
||||
<>
|
||||
<h4 className="font-semibold">
|
||||
Outros indicadores mais recentes do
|
||||
período
|
||||
</h4>
|
||||
<dl className="grid gap-3 sm:grid-cols-2">
|
||||
{demographicHighlights(s.values)
|
||||
.filter(
|
||||
(v) =>
|
||||
v.indicator !==
|
||||
'population',
|
||||
)
|
||||
.map((v) => (
|
||||
<div
|
||||
className="rounded border p-3"
|
||||
key={`${v.sheet}:${v.cell}`}
|
||||
>
|
||||
<dt>
|
||||
{indicators[
|
||||
v.indicator
|
||||
] ?? v.indicator}{' '}
|
||||
· {v.year}
|
||||
</dt>
|
||||
<dd className="text-lg font-semibold">
|
||||
{v.original_value}{' '}
|
||||
{v.unit ===
|
||||
'unspecified'
|
||||
? '(unidade não indicada)'
|
||||
: v.unit}
|
||||
</dd>
|
||||
<dd className="text-sm">
|
||||
{v.data_kind ===
|
||||
'projected'
|
||||
? 'Projecção'
|
||||
: 'Tipo estatístico não especificado'}
|
||||
</dd>
|
||||
{v.validation_status !==
|
||||
'valid' && (
|
||||
<dd className="text-sm">
|
||||
Valor com
|
||||
advertência na
|
||||
fonte; consulte o
|
||||
detalhe antes de o
|
||||
utilizar.
|
||||
</dd>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</>
|
||||
)}
|
||||
{s.missing_years.length > 0 && (
|
||||
<p>
|
||||
Anos sem dados: {s.missing_years.join(', ')}
|
||||
. Não foram preenchidos por estimativa.
|
||||
</p>
|
||||
)}
|
||||
{Object.keys(s.issue_counts).length > 0 && (
|
||||
<details>
|
||||
<summary>Advertências da série</summary>
|
||||
<pre className="overflow-auto text-xs">
|
||||
{JSON.stringify(
|
||||
s.issue_counts,
|
||||
null,
|
||||
2,
|
||||
)}
|
||||
</pre>
|
||||
</details>
|
||||
{(Object.keys(s.issue_counts).length > 0 ||
|
||||
s.values.some(
|
||||
(v) => v.validation_status !== 'valid',
|
||||
)) && (
|
||||
<p>
|
||||
Esta série contém advertências. Consulte-as
|
||||
antes de comparar ou utilizar os valores.
|
||||
</p>
|
||||
)}
|
||||
<div className="max-h-96 overflow-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<caption className="text-left">
|
||||
Valores originais por ano e dimensão —
|
||||
versões apresentadas separadamente
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
{[
|
||||
'Ano',
|
||||
'Indicador',
|
||||
'Idade',
|
||||
'Residência',
|
||||
'Valor',
|
||||
'Unidade',
|
||||
'Tipo',
|
||||
'Referência',
|
||||
].map((h) => (
|
||||
<th className="p-2" key={h}>
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{s.values.map((v) => (
|
||||
<tr
|
||||
key={`${v.sheet}:${v.cell}`}
|
||||
className="border-t"
|
||||
>
|
||||
<td className="p-2">
|
||||
{v.year}
|
||||
</td>
|
||||
<td>
|
||||
{indicators[v.indicator] ??
|
||||
v.indicator}
|
||||
</td>
|
||||
<td>
|
||||
{v.age_group === 'all'
|
||||
? 'Todas'
|
||||
: v.age_group}
|
||||
</td>
|
||||
<td>
|
||||
{
|
||||
{
|
||||
all: 'Total',
|
||||
urban: 'Urbana',
|
||||
rural: 'Rural',
|
||||
}[v.residence]
|
||||
}
|
||||
</td>
|
||||
<td>{v.original_value}</td>
|
||||
<td>
|
||||
{v.unit === 'unspecified'
|
||||
? 'Não indicada na fonte'
|
||||
: v.unit}
|
||||
</td>
|
||||
<td>
|
||||
{v.data_kind === 'projected'
|
||||
? 'Projecção'
|
||||
: 'Não especificado'}
|
||||
</td>
|
||||
<td>
|
||||
{v.sheet}!{v.cell}
|
||||
</td>
|
||||
<EvidenceDetails title="Valores por dimensão, fonte e advertências">
|
||||
<p>
|
||||
{s.version} · {s.file_name}
|
||||
</p>
|
||||
<p className="text-xs break-all">
|
||||
SHA256: {s.sha256}
|
||||
</p>
|
||||
{Object.keys(s.issue_counts).length > 0 && (
|
||||
<details>
|
||||
<summary>Advertências da série</summary>
|
||||
<pre className="overflow-auto text-xs">
|
||||
{JSON.stringify(
|
||||
s.issue_counts,
|
||||
null,
|
||||
2,
|
||||
)}
|
||||
</pre>
|
||||
</details>
|
||||
)}
|
||||
<div className="max-h-96 overflow-auto">
|
||||
<table className="w-full min-w-[44rem] text-left text-sm whitespace-nowrap">
|
||||
<caption className="text-left">
|
||||
Valores originais por ano e dimensão
|
||||
— versões apresentadas separadamente
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
{[
|
||||
'Ano',
|
||||
'Indicador',
|
||||
'Idade',
|
||||
'Residência',
|
||||
'Valor',
|
||||
'Unidade',
|
||||
'Tipo',
|
||||
'Referência',
|
||||
].map((h) => (
|
||||
<th className="p-2" key={h}>
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</details>
|
||||
</thead>
|
||||
<tbody>
|
||||
{s.values.map((v) => (
|
||||
<tr
|
||||
key={`${v.sheet}:${v.cell}`}
|
||||
className="border-t"
|
||||
>
|
||||
<td className="p-2">
|
||||
{v.year}
|
||||
</td>
|
||||
<td>
|
||||
{indicators[
|
||||
v.indicator
|
||||
] ?? v.indicator}
|
||||
</td>
|
||||
<td>
|
||||
{v.age_group === 'all'
|
||||
? 'Todas'
|
||||
: v.age_group}
|
||||
</td>
|
||||
<td>
|
||||
{
|
||||
{
|
||||
all: 'Total',
|
||||
urban: 'Urbana',
|
||||
rural: 'Rural',
|
||||
}[v.residence]
|
||||
}
|
||||
</td>
|
||||
<td>{v.original_value}</td>
|
||||
<td>
|
||||
{v.unit ===
|
||||
'unspecified'
|
||||
? 'Não indicada na fonte'
|
||||
: v.unit}
|
||||
</td>
|
||||
<td>
|
||||
{v.data_kind ===
|
||||
'projected'
|
||||
? 'Projecção'
|
||||
: 'Não especificado'}
|
||||
</td>
|
||||
<td>
|
||||
{v.sheet}!{v.cell}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</EvidenceDetails>
|
||||
</section>
|
||||
))}
|
||||
</article>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user