Consolida rastreabilidade territorial e plano autenticado V2

This commit is contained in:
2026-10-09 02:05:44 +02:00
parent 30acdc9934
commit 6a71aa47e3
33 changed files with 2555 additions and 49 deletions
@@ -1,4 +1,8 @@
import { Link } from '@inertiajs/react';
import TerritorialSources, {
type TerritorialSourceEvidence,
} from './territorial-source-evidence';
import type { GeoJsonObject } from 'geojson';
import InteractiveInvestmentMap from './interactive-investment-map';
export type DocumentedLocation = {
@@ -6,15 +10,24 @@ export type DocumentedLocation = {
name: string;
role: string;
source_reference?: string;
source_date?: string | null;
boundaries?: {
geometry_id: string;
source_reference: string | null;
source_date: string | null;
geometry: GeoJsonObject;
}[];
location_type: string;
path: { id: string; name: string; location_type: string }[];
coordinates: {
geometry_id: string;
source_reference: string;
source_reference: string | null;
source_date?: string | null;
geometry: { coordinates: [number, number] };
}[];
};
export type StructureGeography = {
source_evidence?: TerritorialSourceEvidence[];
locations: DocumentedLocation[];
members: {
id: string;
@@ -44,6 +57,7 @@ export type StructureGeography = {
};
const roles: Record<string, string> = {
opportunity: 'Implantação cadastrada da oportunidade',
primary: 'Localização principal',
secondary: 'Localização secundária',
impact: 'Área de impacto',
@@ -85,11 +99,13 @@ export function LocationList({
<p key={point.geometry_id}>
Coordenadas documentadas (
{location.location_type === 'site'
? 'local do projecto'
? 'local cadastrado; não confirma a implantação da oportunidade'
: 'referência territorial; não representa a implantação'}
): {point.geometry.coordinates[1]},{' '}
{point.geometry.coordinates[0]} · Fonte:{' '}
{point.source_reference}
{point.source_reference ?? 'Não indicada'}
{' · Data da fonte: '}
{point.source_date ?? 'Não documentada'}
</p>
))}
{!location.coordinates.length && (
@@ -98,7 +114,20 @@ export function LocationList({
<p className="text-sm">
Fonte da relação:{' '}
{location.source_reference ?? 'Não indicada'}
{' · Data da fonte: '}
{location.source_date ?? 'Não documentada'}
</p>
{location.boundaries?.map((boundary) => (
<p key={boundary.geometry_id}>
Polígono cadastrado · Fonte:{' '}
{boundary.source_reference ?? 'Não indicada'} ·
Data: {boundary.source_date ?? 'Não documentada'}. O
cadastro não certifica limites oficiais.
</p>
))}
{!location.boundaries?.length && (
<p>Polígono não documentado.</p>
)}
<Link
className="underline"
href={`/oportunidades?geo_location_id=${location.id}`}
@@ -165,6 +194,7 @@ export default function StructureGeographyPanel({
: 'Localização documentada do projecto'}
</h2>
<LocationList locations={geography.locations} />
<TerritorialSources sources={geography.source_evidence} />
{!geography.locations.length && (
<p>
{cluster
@@ -178,7 +208,27 @@ export default function StructureGeographyPanel({
um ponto único atribuído ao cluster.
</p>
)}
<InteractiveInvestmentMap points={points} />
<InteractiveInvestmentMap
points={points}
areas={[
...items.flatMap((item) =>
(item.location.boundaries ?? []).map((area) => ({
...area,
title: `${roles[item.location.role] ?? item.location.role} · ${item.title}`,
url: item.url,
})),
),
...(cluster
? geography.locations.flatMap((location) =>
(location.boundaries ?? []).map((area) => ({
...area,
title: `Abrangência do cluster · ${location.name}`,
url: `/carteira/${dossierId}`,
})),
)
: []),
]}
/>
{!points.length && (
<p>
Sem coordenadas documentadas dos locais. Nenhum ponto foi