|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
|
import Image from "next/image"; |
|
|
import Image from "next/image"; |
|
|
import { useRouter } from "next/navigation"; |
|
|
import { useRouter } from "next/navigation"; |
|
|
import { useMemo, useState } from "react"; |
|
|
|
|
|
|
|
|
import { useEffect, useMemo, useState } from "react"; |
|
|
import Button from "@/components/ui/button"; |
|
|
import Button from "@/components/ui/button"; |
|
|
import DismissReasonSheet from "@/components/ui/dismiss-reason-sheet"; |
|
|
import DismissReasonSheet from "@/components/ui/dismiss-reason-sheet"; |
|
|
import FemaleConsentSheet from "@/components/ui/female-consent-sheet"; |
|
|
import FemaleConsentSheet from "@/components/ui/female-consent-sheet"; |
|
|
@ -19,6 +19,7 @@ import type { |
|
|
} from "@/hooks/marriage/types"; |
|
|
} from "@/hooks/marriage/types"; |
|
|
import { useRespondToMarriageCaseMutation } from "@/hooks/marriage/use-case-respond"; |
|
|
import { useRespondToMarriageCaseMutation } from "@/hooks/marriage/use-case-respond"; |
|
|
import { useMarriageProfileQuery } from "@/hooks/marriage/use-profile-main"; |
|
|
import { useMarriageProfileQuery } from "@/hooks/marriage/use-profile-main"; |
|
|
|
|
|
import { getSubmitPath } from "@/lib/get-submit-path"; |
|
|
import { localizePath } from "@/translations/config"; |
|
|
import { localizePath } from "@/translations/config"; |
|
|
import { useI18n } from "@/translations/provider"; |
|
|
import { useI18n } from "@/translations/provider"; |
|
|
|
|
|
|
|
|
@ -150,7 +151,18 @@ export default function NewMatchProfilePage() { |
|
|
const [isRejectSheetOpen, setIsRejectSheetOpen] = useState(false); |
|
|
const [isRejectSheetOpen, setIsRejectSheetOpen] = useState(false); |
|
|
const [isDismissReasonSheetOpen, setIsDismissReasonSheetOpen] = |
|
|
const [isDismissReasonSheetOpen, setIsDismissReasonSheetOpen] = |
|
|
useState(false); |
|
|
useState(false); |
|
|
const { data: profile } = useMarriageProfileQuery(); |
|
|
|
|
|
|
|
|
const { data: profile, refetch: refetchProfile } = useMarriageProfileQuery(); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
if (!profile) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
const targetPath = getSubmitPath(profile); |
|
|
|
|
|
if (targetPath !== "/new-match") { |
|
|
|
|
|
router.replace(localizePath(targetPath, locale)); |
|
|
|
|
|
} |
|
|
|
|
|
}, [profile, locale, router]); |
|
|
|
|
|
|
|
|
const caseId = profile?.active_case?.case_id; |
|
|
const caseId = profile?.active_case?.case_id; |
|
|
const caseStatus = profile?.active_case?.status; |
|
|
const caseStatus = profile?.active_case?.status; |
|
|
const isFemaleProfile = profile?.gender === "female"; |
|
|
const isFemaleProfile = profile?.gender === "female"; |
|
|
@ -158,11 +170,9 @@ export default function NewMatchProfilePage() { |
|
|
const respondMutation = useRespondToMarriageCaseMutation(caseId ?? "", { |
|
|
const respondMutation = useRespondToMarriageCaseMutation(caseId ?? "", { |
|
|
onSuccess: async (_, variables) => { |
|
|
onSuccess: async (_, variables) => { |
|
|
if (variables.action === "accept") { |
|
|
if (variables.action === "accept") { |
|
|
if (isFemaleProfile) { |
|
|
|
|
|
router.replace(localizePath("/request-accepted", locale)); |
|
|
|
|
|
} else { |
|
|
|
|
|
router.replace(localizePath("/request-sent", locale)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const { data: updatedProfile } = await refetchProfile(); |
|
|
|
|
|
const nextPath = getSubmitPath(updatedProfile); |
|
|
|
|
|
router.replace(localizePath(nextPath, locale)); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|