From d7834465965b9ce567c9a5f0cb8d6fd7dc992b29 Mon Sep 17 00:00:00 2001 From: anamontiaga Date: Mon, 18 Sep 2023 11:04:18 +0200 Subject: [PATCH] remove query options --- app/hooks/wdpa/index.ts | 7 +++---- .../project/inventory-panel/wdpas/index.tsx | 20 ++++--------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/app/hooks/wdpa/index.ts b/app/hooks/wdpa/index.ts index 1f755ed66d..9470096192 100644 --- a/app/hooks/wdpa/index.ts +++ b/app/hooks/wdpa/index.ts @@ -89,10 +89,9 @@ export function useSaveScenarioProtectedAreas({ return useMutation(saveScenarioProtectedAreas); } -export function useProjectWDPAs( +export function useProjectWDPAs( pid: Project['id'], - params: { search?: string; sort?: string } = {}, - queryOptions: QueryObserverOptions = {} + params: { search?: string; sort?: string } = {} ) { const { data: session } = useSession(); @@ -116,7 +115,7 @@ export function useProjectWDPAs( }, }); - const query = useInfiniteQuery(['wdpas', JSON.stringify(params)], fetchProjectWDPAs, { + const query = useInfiniteQuery(['wdpas', pid, JSON.stringify(params)], fetchProjectWDPAs, { retry: false, keepPreviousData: true, getNextPageParam: (lastPage) => { diff --git a/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx b/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx index 1bf1e1d8b7..09d5770a2b 100644 --- a/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx @@ -40,22 +40,10 @@ const InventoryPanelProtectedAreas = ({ sort: WDPA_TABLE_COLUMNS[0].name, }); - const allProjectWDPAsQuery = useProjectWDPAs( - pid, - { - ...filters, - search, - }, - { - select: (data) => - data?.map((wdpa) => ({ - id: wdpa.id, - attributes: wdpa.attributes, - })), - keepPreviousData: true, - placeholderData: [], - } - ); + const allProjectWDPAsQuery = useProjectWDPAs(pid, { + ...filters, + search, + }); const WDPAIds = allProjectWDPAsQuery.data ?.filter((wdpa) => wdpa.attributes.isCustom)