Browse Source

fix redirect page

master
mortezaei 11 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";
}, [profile]);
if (isLoading || isRedirecting) {
if ((isLoading && !profile) || !profile) {
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 (
<>
<PageBackground />
@ -627,7 +627,7 @@ export default function NewMatchClient() {
<main
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"
>

3
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 (
<NewMatchProfileSkeleton
hideBackButton={isSubmitting}

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

@ -36,7 +36,17 @@ export function useRespondToMarriageCaseMutation(
...options,
mutationFn: (payload) => 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({
queryClient.invalidateQueries({
queryKey: marriageQueryKeys.profile(),
}),
});
queryClient.invalidateQueries({
queryKey: marriageQueryKeys.contactInfo(caseId),
}),
]);
});
await options?.onSuccess?.(data, variables, onMutateResult, context);
},
});

Loading…
Cancel
Save