Skip to content

Commit

Permalink
Fix querykey
Browse files Browse the repository at this point in the history
  • Loading branch information
andersrognstad committed Dec 4, 2023
1 parent 0ba5dbe commit 7d279dc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/data/personregisterHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { ApiErrorException } from '@/api/errors';
import { FetchPersonregisterFailed } from '@/context/notification/Notifications';
import { useNotifications } from '@/context/notification/NotificationContext';
import { useAsyncError } from '@/data/useAsyncError';
import { useAktivEnhet } from '@/context/aktivEnhet/AktivEnhetContext';

export const personregisterQueryKeys = {
personregister: ['personregister'],
personregister: (enhetId: string | undefined) => ['personregister', enhetId],
};

export const usePersonregisterQuery = () => {
const { aktivEnhet } = useAktivEnhet();
const { data } = usePersonoversiktQuery();
const { displayNotification, clearNotification } = useNotifications();
const throwError = useAsyncError();
Expand All @@ -29,9 +31,9 @@ export const usePersonregisterQuery = () => {
};

return useQuery({
queryKey: personregisterQueryKeys.personregister,
queryKey: personregisterQueryKeys.personregister(aktivEnhet),
queryFn: fetchPersonregister,
enabled: fnrForPersonerListe.length > 0,
enabled: !!aktivEnhet && fnrForPersonerListe.length > 0,
onError: (error) => {
if (error instanceof ApiErrorException && error.code === 403) {
throwError(error);
Expand Down

0 comments on commit 7d279dc

Please sign in to comment.