Consolida rastreabilidade territorial e plano autenticado V2
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import InteractiveInvestmentMap, {
|
||||
type InvestmentMapFeature,
|
||||
type InvestmentMapArea,
|
||||
} from './interactive-investment-map';
|
||||
|
||||
export default function InvestmentMapPanel({
|
||||
@@ -14,10 +15,12 @@ export default function InvestmentMapPanel({
|
||||
{ id: number; title: string; url: string }[]
|
||||
>([]);
|
||||
const [error, setError] = useState('');
|
||||
const [areas, setAreas] = useState<InvestmentMapArea[]>([]);
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
const params = new URLSearchParams(JSON.parse(key));
|
||||
setPoints(null);
|
||||
setAreas([]);
|
||||
fetch(`/api/v1/investment/map?${params}`, {
|
||||
signal: controller.signal,
|
||||
headers: { Accept: 'application/json' },
|
||||
@@ -29,6 +32,7 @@ export default function InvestmentMapPanel({
|
||||
.then((data) => {
|
||||
if (controller.signal.aborted) return;
|
||||
setPoints(data.features);
|
||||
setAreas(data.areas ?? []);
|
||||
setMissing(data.unlocated ?? []);
|
||||
setError(
|
||||
data.truncated
|
||||
@@ -44,12 +48,13 @@ export default function InvestmentMapPanel({
|
||||
return (
|
||||
<section className="space-y-3">
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<InteractiveInvestmentMap points={points} />
|
||||
<InteractiveInvestmentMap points={points} areas={areas} />
|
||||
{missing.length > 0 && (
|
||||
<div>
|
||||
<p>
|
||||
{missing.length} investimentos aguardam coordenadas do
|
||||
local:
|
||||
{missing.length} investimentos sem ponto público
|
||||
utilizável. Consulte as fichas para localizações
|
||||
documentadas sem coordenadas:
|
||||
</p>
|
||||
<ul>
|
||||
{missing.map((record) => (
|
||||
|
||||
Reference in New Issue
Block a user