From 78e4e08da79aa73d320af961d58dc24c51611e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Tue, 6 Feb 2024 13:18:44 +0100 Subject: [PATCH] solutions report: displays only selected WDPA in scenario --- app/hooks/wdpa/index.ts | 2 +- .../reports/solutions/resume/index.tsx | 21 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/hooks/wdpa/index.ts b/app/hooks/wdpa/index.ts index 58135c5cff..689ddca825 100644 --- a/app/hooks/wdpa/index.ts +++ b/app/hooks/wdpa/index.ts @@ -43,7 +43,7 @@ export function useWDPACategories({ }, }).then(({ data }) => data), { - enabled: !!adminAreaId || !!customAreaId, + // enabled: !!adminAreaId || !!customAreaId, } ); } diff --git a/app/layout/scenarios/reports/solutions/resume/index.tsx b/app/layout/scenarios/reports/solutions/resume/index.tsx index 6b87469fbc..b82a79b22f 100644 --- a/app/layout/scenarios/reports/solutions/resume/index.tsx +++ b/app/layout/scenarios/reports/solutions/resume/index.tsx @@ -6,13 +6,16 @@ import { useProjectCostSurfaces } from 'hooks/cost-surface'; import { useProjectUsers } from 'hooks/project-users'; import { useProject } from 'hooks/projects'; import { useScenario, useScenarioPU } from 'hooks/scenarios'; -import { useProjectWDPAs } from 'hooks/wdpa'; +import { useWDPACategories } from 'hooks/wdpa'; export const ResumePage = (): JSX.Element => { const { query } = useRouter(); const { pid, sid } = query as { pid: string; sid: string }; const projectQuery = useProject(pid); const scenarioQuery = useScenario(sid); + const ScenarioWPDACategoriesQuery = useWDPACategories({ + scenarioId: sid, + }); const costSurfaceQuery = useProjectCostSurfaces( pid, @@ -23,17 +26,13 @@ export const ResumePage = (): JSX.Element => { } ); - const protectedAreaQuery = useProjectWDPAs( - pid, - { sort: 'name' }, - { - select: (data) => data.map(({ id, name }) => ({ id, name })), - } - ); - const projectUsersQuery = useProjectUsers(pid); const PUDataQuery = useScenarioPU(sid); + const selectedScenarioWDPACategories = ScenarioWPDACategoriesQuery.data + ?.filter(({ selected }) => selected) + .map(({ name }) => name); + const SECTION_CLASSES = 'pb-6'; const TITLE_CLASSES = 'pb-3 text-sm font-semibold'; const TEXT_CLASSES = 'text-sm leading-4'; @@ -79,9 +78,7 @@ export const ResumePage = (): JSX.Element => {

Conservation Areas:

-

- {protectedAreaQuery.data?.map(({ name }) => name).join(', ')} -

+

{selectedScenarioWDPACategories?.join(', ')}