232 lines
10 KiB
TypeScript
232 lines
10 KiB
TypeScript
export type DemographicAnalysis = {
|
|
state: string;
|
|
start_year: number;
|
|
end_year: number;
|
|
limitations: string[];
|
|
comparisons: {
|
|
year: number;
|
|
left: string;
|
|
right: string;
|
|
left_value: string;
|
|
right_value: string;
|
|
left_import: string;
|
|
right_import: string;
|
|
difference: string | null;
|
|
explanation: string;
|
|
}[];
|
|
differences: {
|
|
territory_id: string;
|
|
dimension: string;
|
|
state: string;
|
|
values: { import_id: string; value: string; data_kind: string }[];
|
|
}[];
|
|
territories: {
|
|
id: string;
|
|
name: string;
|
|
level: string;
|
|
factors_to_assess: string[];
|
|
series: {
|
|
import_id: string;
|
|
source: string;
|
|
version: string;
|
|
sha256: string;
|
|
file_name: string;
|
|
missing_years: number[];
|
|
issue_counts: Record<string, number>;
|
|
values: {
|
|
year: number;
|
|
indicator: string;
|
|
age_group: string;
|
|
residence: string;
|
|
value: string;
|
|
original_value: string;
|
|
unit: string;
|
|
data_kind: string;
|
|
sheet: string;
|
|
cell: string;
|
|
validation_status: string;
|
|
}[];
|
|
}[];
|
|
}[];
|
|
};
|
|
|
|
const indicators: Record<string, string> = {
|
|
population: 'População',
|
|
life_expectancy: 'Esperança de vida',
|
|
infant_mortality: 'Mortalidade infantil',
|
|
crude_death_rate: 'Mortalidade bruta',
|
|
crude_birth_rate: 'Natalidade bruta',
|
|
fertility_rate: 'Fecundidade',
|
|
population_growth_rate: 'Crescimento populacional',
|
|
};
|
|
export default function DemographicEvidence({
|
|
evidence,
|
|
}: {
|
|
evidence: DemographicAnalysis;
|
|
}) {
|
|
return (
|
|
<section className="space-y-4" aria-label="Evidência demográfica">
|
|
{evidence.state !== 'available' && (
|
|
<p>Sem séries demográficas aprovadas para esta selecção.</p>
|
|
)}
|
|
{evidence.territories.map((t) => (
|
|
<article
|
|
key={t.id}
|
|
className="space-y-3 rounded border bg-white p-4 text-slate-900"
|
|
>
|
|
<h2 className="text-xl font-semibold">
|
|
{t.name} —{' '}
|
|
{t.level === 'district' ? 'Distrito' : 'Província'}
|
|
</h2>
|
|
{t.factors_to_assess.map((f) => (
|
|
<p key={f}>{f}</p>
|
|
))}
|
|
{t.series.length === 0 && (
|
|
<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>
|
|
{s.missing_years.length > 0 && (
|
|
<p>
|
|
Anos sem dados: {s.missing_years.join(', ')}
|
|
</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 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>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</details>
|
|
))}
|
|
</article>
|
|
))}
|
|
{evidence.comparisons.length > 0 && (
|
|
<section className="space-y-3">
|
|
<h2 className="text-xl font-semibold">
|
|
Diferenças entre localizações
|
|
</h2>
|
|
{evidence.comparisons.map((c) => (
|
|
<p
|
|
key={`${c.year}:${c.left_import}:${c.right_import}:${c.left}:${c.right}`}
|
|
>
|
|
{c.year}: {c.left} ({c.left_value}) / {c.right} (
|
|
{c.right_value}). Diferença:{' '}
|
|
{c.difference ?? 'não comparável'}. {c.explanation}
|
|
</p>
|
|
))}
|
|
</section>
|
|
)}
|
|
{evidence.differences.length > 0 && (
|
|
<details>
|
|
<summary>
|
|
Reconciliação entre exemplares:{' '}
|
|
{evidence.differences.length} dimensões comuns
|
|
</summary>
|
|
<ul>
|
|
{evidence.differences.map((d) => (
|
|
<li key={`${d.territory_id}:${d.dimension}`}>
|
|
{d.dimension}:{' '}
|
|
{d.state === 'matching_values'
|
|
? 'valores coincidentes; conservar ambas as fontes'
|
|
: 'valores divergentes'}{' '}
|
|
—{' '}
|
|
{d.values
|
|
.map((v) => `${v.value} (${v.data_kind})`)
|
|
.join(' / ')}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</details>
|
|
)}
|
|
<ul className="list-disc pl-5 text-sm">
|
|
{evidence.limitations.map((l) => (
|
|
<li key={l}>{l}</li>
|
|
))}
|
|
</ul>
|
|
</section>
|
|
);
|
|
}
|