feat: show immediate administrative subdivisions and map coverage gaps

This commit is contained in:
2026-11-04 10:58:28 +02:00
parent 6dde36b5ca
commit bbc05f1df6
12 changed files with 399 additions and 26 deletions
@@ -6,13 +6,21 @@ export type TerritoryGeometryContext = {
context_geometry_count: number;
areas: InvestmentMapArea[];
truncated: boolean;
child_coverage?: {
location_type: string | null;
registered_count: number;
represented_count: number;
reference_limit: number;
geometry_limit: number;
} | null;
};
export function useTerritoryGeometry(
territoryId?: string,
endpoint = '/api/v1/investment/territory-geometries',
includeChildren = false,
) {
const key = JSON.stringify([territoryId, endpoint]);
const key = JSON.stringify([territoryId, endpoint, includeChildren]);
const [result, setResult] = useState<{
key: string;
context: TerritoryGeometryContext | null;
@@ -23,7 +31,7 @@ export function useTerritoryGeometry(
setResult({ key, context: null, error: '' });
if (!territoryId) return () => controller.abort();
void fetch(
`${endpoint}?${new URLSearchParams({ territory_id: territoryId })}`,
`${endpoint}?${new URLSearchParams({ territory_id: territoryId, ...(includeChildren ? { include_children: '1' } : {}) })}`,
{
signal: controller.signal,
headers: { Accept: 'application/json' },
@@ -52,6 +60,6 @@ export function useTerritoryGeometry(
});
});
return () => controller.abort();
}, [key, territoryId, endpoint]);
}, [key, territoryId, endpoint, includeChildren]);
return result.key === key ? result : { key, context: null, error: '' };
}