diff --git a/src/app/finding-match/finding-match-client.tsx b/src/app/finding-match/finding-match-client.tsx index 6ff52cb..e43f671 100644 --- a/src/app/finding-match/finding-match-client.tsx +++ b/src/app/finding-match/finding-match-client.tsx @@ -65,7 +65,7 @@ export default function FindingMatchClient() { return getSubmitPath(profile) !== "/finding-match"; }, [profile]); - if (isLoading || isRedirecting) { + if ((isLoading && !profile) || !profile) { return ; } diff --git a/src/app/new-match/new-match-client.tsx b/src/app/new-match/new-match-client.tsx index d3c3515..8f52cd7 100644 --- a/src/app/new-match/new-match-client.tsx +++ b/src/app/new-match/new-match-client.tsx @@ -619,7 +619,7 @@ export default function NewMatchClient() { } } - if (isLoading || isRedirecting) { + if ((isLoading && !profile) || !profile) { return ( <> @@ -627,7 +627,7 @@ export default function NewMatchClient() {
diff --git a/src/app/new-match/profile/page.tsx b/src/app/new-match/profile/page.tsx index f536eca..43ea8b6 100644 --- a/src/app/new-match/profile/page.tsx +++ b/src/app/new-match/profile/page.tsx @@ -319,6 +319,7 @@ export default function NewMatchProfilePage({ return; } + onClose?.(); router.replace(localizePath("/finding-match", locale)); }, }); @@ -390,7 +391,7 @@ export default function NewMatchProfilePage({ const isSubmitting = respondMutation.isPending; - if (isLoading || !profile || isRedirecting || isSubmitting) { + if ((isLoading && !profile) || !profile) { return ( respondToMarriageCase(caseId, payload), onSuccess: async (data, variables, onMutateResult, context) => { - if (data?.case) { + if (variables?.action === "reject") { + queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { + if (!old) return old; + return { + ...old, + status: "waiting", + active_case: null, + match_summary: null, + }; + }); + } else if (data?.case) { queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { if (!old) return old; const updatedActiveCase = { @@ -63,14 +73,13 @@ export function useRespondToMarriageCaseMutation( }); } - await Promise.all([ - queryClient.refetchQueries({ - queryKey: marriageQueryKeys.profile(), - }), - queryClient.invalidateQueries({ - queryKey: marriageQueryKeys.contactInfo(caseId), - }), - ]); + queryClient.invalidateQueries({ + queryKey: marriageQueryKeys.profile(), + }); + queryClient.invalidateQueries({ + queryKey: marriageQueryKeys.contactInfo(caseId), + }); + await options?.onSuccess?.(data, variables, onMutateResult, context); }, });