You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.0 KiB
78 lines
2.0 KiB
import type { MarriageProfileResponse } from "@/hooks/marriage/types";
|
|
import {
|
|
clearLegacyMatchSubmittedFlag,
|
|
isWithinMatchStartGrace,
|
|
} from "./match-start-grace";
|
|
|
|
export function getSubmitPath(profile: MarriageProfileResponse | undefined) {
|
|
clearLegacyMatchSubmittedFlag();
|
|
|
|
if (!profile) {
|
|
return "/intro";
|
|
}
|
|
|
|
const activeCase = profile.active_case;
|
|
|
|
if (activeCase) {
|
|
const caseStatus = activeCase.status;
|
|
const myAction = activeCase.my_action;
|
|
const isFemale = profile.gender === "female";
|
|
|
|
if (caseStatus === "payment_done" || caseStatus === "finalized") {
|
|
if (isFemale) {
|
|
return "/candidate-contact";
|
|
}
|
|
return "/request-accepted";
|
|
}
|
|
|
|
if (caseStatus === "payment_pending" || caseStatus === "female_accepted") {
|
|
if (isFemale) {
|
|
return "/candidate-contact";
|
|
}
|
|
return "/request-accepted";
|
|
}
|
|
|
|
if (caseStatus === "male_accepted") {
|
|
if (myAction === "pending") {
|
|
return "/new-match";
|
|
}
|
|
return "/request-sent";
|
|
}
|
|
|
|
if (caseStatus === "introduced") {
|
|
if (myAction === "pending") {
|
|
return "/new-match";
|
|
}
|
|
return "/finding-match";
|
|
}
|
|
|
|
// male_rejected / female_rejected / dismissed – the case is over, the user
|
|
// goes back to waiting for the next match.
|
|
return "/finding-match";
|
|
}
|
|
|
|
if (profile.status === "pending_onboarding") {
|
|
return "/terms";
|
|
}
|
|
|
|
if (profile.status === "waiting") {
|
|
return "/finding-match";
|
|
}
|
|
|
|
if (profile.status === "matched") {
|
|
return "/candidate-contact";
|
|
}
|
|
|
|
if (profile.status === "in_case") {
|
|
return "/finding-match";
|
|
}
|
|
|
|
if (profile.status === "pending_info") {
|
|
// The backend may still report pending_info for a moment right after the
|
|
// match request is sent, so honour a short grace window to avoid bouncing
|
|
// the user back into the questions list.
|
|
return isWithinMatchStartGrace() ? "/finding-match" : "/questions-list";
|
|
}
|
|
|
|
return "/terms";
|
|
}
|