Browse Source

fix client

master
mortezaei 1 day ago
parent
commit
ab3ed39b03
  1. 6
      src/app/questions-list/[slug]/question-detail-client.tsx
  2. 26
      src/hooks/marriage/use-section-data.ts

6
src/app/questions-list/[slug]/question-detail-client.tsx

@ -270,12 +270,16 @@ export default function QuestionDetailClient({
const profileId = useCurrentProfileId(); const profileId = useCurrentProfileId();
const handleExit = useCallback(() => { const handleExit = useCallback(() => {
void queryClient.invalidateQueries({
queryKey: [...marriageQueryKeys.all, "form-overview"],
exact: false,
});
if (onClose) { if (onClose) {
onClose(); onClose();
return; return;
} }
router.replace(questionsListHref); router.replace(questionsListHref);
}, [onClose, questionsListHref, router]);
}, [onClose, questionsListHref, router, queryClient]);
// Hardware back in the detail page = navigate back to questions list. // Hardware back in the detail page = navigate back to questions list.
// QuestionAnswersProvider's pagehide/unmount safety net will flush // QuestionAnswersProvider's pagehide/unmount safety net will flush

26
src/hooks/marriage/use-section-data.ts

@ -149,22 +149,28 @@ export function applyProfilePatchResultToCache(
const slug = String(queryKey[3] ?? ""); const slug = String(queryKey[3] ?? "");
queryClient.setQueryData(queryKey, patchSection(current, slug)); queryClient.setQueryData(queryKey, patchSection(current, slug));
}); });
queryClient.setQueryData(
marriageQueryKeys.formOverview("profile", locale),
(current: any) =>
current
? {
queryClient
.getQueriesData({
queryKey: [...marriageQueryKeys.all, "form-overview"],
})
.forEach(([queryKey, current]: [any, any]) => {
if (!current) return;
queryClient.setQueryData(queryKey, {
...current, ...current,
progress: data.progress, progress: data.progress,
sections: current.sections.map((section: any) => {
sections: current.sections?.map((section: any) => {
const progress = const progress =
data.affected_sections[section.id] ?? data.affected_sections[section.id] ??
data.progress.sections_progress[section.id];
data.progress?.sections_progress?.[section.id];
return progress ? { ...section, progress } : section; return progress ? { ...section, progress } : section;
}), }),
}
: current,
);
});
});
void queryClient.invalidateQueries({
queryKey: [...marriageQueryKeys.all, "form-overview"],
exact: false,
});
} }
export function useMarriageSectionDataQuery( export function useMarriageSectionDataQuery(

Loading…
Cancel
Save