Skip to content

Commit

Permalink
remove query options
Browse files Browse the repository at this point in the history
  • Loading branch information
anamontiaga committed Sep 18, 2023
1 parent f8b3adb commit d783446
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
7 changes: 3 additions & 4 deletions app/hooks/wdpa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ export function useSaveScenarioProtectedAreas({
return useMutation(saveScenarioProtectedAreas);
}

export function useProjectWDPAs<T = WDPA[]>(
export function useProjectWDPAs(
pid: Project['id'],
params: { search?: string; sort?: string } = {},
queryOptions: QueryObserverOptions<WDPA[], Error, T> = {}
params: { search?: string; sort?: string } = {}
) {
const { data: session } = useSession();

Expand All @@ -116,7 +115,7 @@ export function useProjectWDPAs<T = WDPA[]>(
},
});

const query = useInfiniteQuery(['wdpas', JSON.stringify(params)], fetchProjectWDPAs, {
const query = useInfiniteQuery(['wdpas', pid, JSON.stringify(params)], fetchProjectWDPAs, {
retry: false,
keepPreviousData: true,
getNextPageParam: (lastPage) => {
Expand Down
20 changes: 4 additions & 16 deletions app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d783446

Please sign in to comment.