@@ -13,9 +13,11 @@ type Context = {
|
||||
export default function TerritoryGeometryPreview({
|
||||
territoryId,
|
||||
management = false,
|
||||
endpoint: suppliedEndpoint,
|
||||
}: {
|
||||
territoryId?: string;
|
||||
management?: boolean;
|
||||
endpoint?: string;
|
||||
}) {
|
||||
const [context, setContext] = useState<Context | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
@@ -24,9 +26,9 @@ export default function TerritoryGeometryPreview({
|
||||
setError('');
|
||||
if (!territoryId) return;
|
||||
const controller = new AbortController();
|
||||
const endpoint = management
|
||||
const endpoint = suppliedEndpoint ?? (management
|
||||
? '/management/territory-geometries'
|
||||
: '/api/v1/investment/territory-geometries';
|
||||
: '/api/v1/investment/territory-geometries');
|
||||
void fetch(
|
||||
`${endpoint}?${new URLSearchParams({ territory_id: territoryId })}`,
|
||||
{
|
||||
@@ -51,7 +53,7 @@ export default function TerritoryGeometryPreview({
|
||||
);
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, [territoryId, management]);
|
||||
}, [territoryId, management, suppliedEndpoint]);
|
||||
if (!territoryId) return null;
|
||||
return (
|
||||
<section
|
||||
@@ -66,7 +68,7 @@ export default function TerritoryGeometryPreview({
|
||||
<p role="status">
|
||||
{context.selected_geometry_available
|
||||
? 'Limite administrativo disponível para este território.'
|
||||
: 'Sem limite administrativo disponível para este território.'}
|
||||
: 'Sem limite administrativo acessível para este território neste perfil.'}
|
||||
</p>
|
||||
<p>
|
||||
{context.context_geometry_count} limites disponíveis na
|
||||
|
||||
Reference in New Issue
Block a user