Browse Source

fix redirect page

master
mortezaei 13 hours ago
parent
commit
8604436149
  1. 2
      src/app/finding-match/finding-match-client.tsx
  2. 4
      src/app/new-match/new-match-client.tsx
  3. 3
      src/app/new-match/profile/page.tsx
  4. 21
      src/hooks/marriage/use-case-respond.ts

2
src/app/finding-match/finding-match-client.tsx

@ -65,7 +65,7 @@ export default function FindingMatchClient() {
return getSubmitPath(profile) !== "/finding-match"; return getSubmitPath(profile) !== "/finding-match";
}, [profile]); }, [profile]);
if (isLoading || isRedirecting) {
if ((isLoading && !profile) || !profile) {
return <PageLoadingSkeleton />; return <PageLoadingSkeleton />;
} }

4
src/app/new-match/new-match-client.tsx

@ -619,7 +619,7 @@ export default function NewMatchClient() {
} }
} }
if (isLoading || isRedirecting) {
if ((isLoading && !profile) || !profile) {
return ( return (
<> <>
<PageBackground /> <PageBackground />
@ -627,7 +627,7 @@ export default function NewMatchClient() {
<main <main
style={{ style={{
paddingBottom: `${profile?.can_edit_profile === false ? 84 + bottom : 20 + bottom}px`,
paddingBottom: `${20 + bottom}px`,
}} }}
className="min-h-0 flex-1 flex flex-col gap-3.5 pt-4 pb-1 text-center" className="min-h-0 flex-1 flex flex-col gap-3.5 pt-4 pb-1 text-center"
> >

3
src/app/new-match/profile/page.tsx

@ -319,6 +319,7 @@ export default function NewMatchProfilePage({
return; return;
} }
onClose?.();
router.replace(localizePath("/finding-match", locale)); router.replace(localizePath("/finding-match", locale));
}, },
}); });
@ -390,7 +391,7 @@ export default function NewMatchProfilePage({
const isSubmitting = respondMutation.isPending; const isSubmitting = respondMutation.isPending;
if (isLoading || !profile || isRedirecting || isSubmitting) {
if ((isLoading && !profile) || !profile) {
return ( return (
<NewMatchProfileSkeleton <NewMatchProfileSkeleton
hideBackButton={isSubmitting} hideBackButton={isSubmitting}

21
src/hooks/marriage/use-case-respond.ts

@ -36,7 +36,17 @@ export function useRespondToMarriageCaseMutation(
...options, ...options,
mutationFn: (payload) => respondToMarriageCase(caseId, payload), mutationFn: (payload) => respondToMarriageCase(caseId, payload),
onSuccess: async (data, variables, onMutateResult, context) => { 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) => { queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => {
if (!old) return old; if (!old) return old;
const updatedActiveCase = { const updatedActiveCase = {
@ -63,14 +73,13 @@ export function useRespondToMarriageCaseMutation(
}); });
} }
await Promise.all([
queryClient.refetchQueries({
queryClient.invalidateQueries({
queryKey: marriageQueryKeys.profile(), queryKey: marriageQueryKeys.profile(),
}),
});
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: marriageQueryKeys.contactInfo(caseId), queryKey: marriageQueryKeys.contactInfo(caseId),
}),
]);
});
await options?.onSuccess?.(data, variables, onMutateResult, context); await options?.onSuccess?.(data, variables, onMutateResult, context);
}, },
}); });

Loading…
Cancel
Save