@@ -14,10 +14,12 @@ export default function TerritoryGeometryPreview({
|
||||
territoryId,
|
||||
management = false,
|
||||
endpoint: suppliedEndpoint,
|
||||
label = 'Cobertura cartográfica da seleção',
|
||||
}: {
|
||||
territoryId?: string;
|
||||
management?: boolean;
|
||||
endpoint?: string;
|
||||
label?: string;
|
||||
}) {
|
||||
const [context, setContext] = useState<Context | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
@@ -26,9 +28,11 @@ export default function TerritoryGeometryPreview({
|
||||
setError('');
|
||||
if (!territoryId) return;
|
||||
const controller = new AbortController();
|
||||
const endpoint = suppliedEndpoint ?? (management
|
||||
? '/management/territory-geometries'
|
||||
: '/api/v1/investment/territory-geometries');
|
||||
const endpoint =
|
||||
suppliedEndpoint ??
|
||||
(management
|
||||
? '/management/territory-geometries'
|
||||
: '/api/v1/investment/territory-geometries');
|
||||
void fetch(
|
||||
`${endpoint}?${new URLSearchParams({ territory_id: territoryId })}`,
|
||||
{
|
||||
@@ -56,10 +60,7 @@ export default function TerritoryGeometryPreview({
|
||||
}, [territoryId, management, suppliedEndpoint]);
|
||||
if (!territoryId) return null;
|
||||
return (
|
||||
<section
|
||||
className="space-y-2 md:col-span-full"
|
||||
aria-label="Cobertura cartográfica da seleção"
|
||||
>
|
||||
<section className="space-y-2 md:col-span-full" aria-label={label}>
|
||||
<p>Território selecionado no cadastro.</p>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
{!context && !error && <p role="status">A consultar geometria…</p>}
|
||||
|
||||
Reference in New Issue
Block a user