Skip to content

Commit b31d800

Browse files
committed
fix: force rerender of nav items on setup state change
1 parent ebc2550 commit b31d800

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { useNotificationsStore } from '@douglasneuroinformatics/libui/hooks';
22
import type { UpdateSetupStateData } from '@opendatacapture/schemas/setup';
3-
import { useMutation } from '@tanstack/react-query';
3+
import { useMutation, useQueryClient } from '@tanstack/react-query';
44
import axios from 'axios';
55

66
export function useUpdateSetupStateMutation() {
7+
const queryClient = useQueryClient();
78
const addNotification = useNotificationsStore((store) => store.addNotification);
89
return useMutation({
910
mutationFn: async (data: UpdateSetupStateData) => {
1011
await axios.patch('/v1/setup', data);
1112
},
1213
onSuccess() {
1314
addNotification({ type: 'success' });
15+
void queryClient.invalidateQueries({ queryKey: ['setup-state'] });
1416
}
1517
});
1618
}

apps/web/src/hooks/useNavItems.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function useNavItems() {
127127
});
128128
}
129129
setNavItems([globalItems, adminItems, sessionItems].filter((arr) => arr.length));
130-
}, [currentSession, currentUser, resolvedLanguage]);
130+
}, [currentSession, currentUser, resolvedLanguage, setupState.data?.isExperimentalFeaturesEnabled]);
131131

132132
return navItems;
133133
}

0 commit comments

Comments
 (0)