feat(auth): add registration and verification browser flow
This commit is contained in:
1 parent
391af7a1ef
commit
b2322bc178
41 files changed
+2144
-81
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { Account } from "../../../shared/api/schemas";
|
||||
import { paths } from "../../../shared/config";
|
||||
import { getOnboardingDestination } from "./onboarding-destination";
|
||||
|
||||
function account(
|
||||
scenario: Account["scenario"],
|
||||
onboarding_step: Account["onboarding_step"],
|
||||
): Pick<Account, "scenario" | "onboarding_step"> {
|
||||
return { scenario, onboarding_step };
|
||||
}
|
||||
|
||||
describe("getOnboardingDestination", () => {
|
||||
it.each([
|
||||
["candidate", "candidate_consents", paths.candidate.onboarding],
|
||||
["candidate", "candidate_profile", paths.candidate.profile],
|
||||
["candidate", "candidate_questionnaire", paths.candidate.onboarding],
|
||||
["candidate", "candidate_assessment", paths.candidate.assessment],
|
||||
["candidate", "completed", paths.candidate.root],
|
||||
["employer", "employer_company", paths.employer.company],
|
||||
["employer", "completed", paths.employer.root],
|
||||
["candidate", "employer_company", paths.candidate.onboarding],
|
||||
] as const)("routes %s at %s to the saved step", (scenario, step, expected) => {
|
||||
expect(getOnboardingDestination(account(scenario, step))).toBe(expected);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { Account } from "../../../shared/api/schemas";
|
||||
import { paths } from "../../../shared/config";
|
||||
|
||||
/** Resolve the next page from the server-owned onboarding state. */
|
||||
export function getOnboardingDestination(
|
||||
account: Pick<Account, "scenario" | "onboarding_step">,
|
||||
): string {
|
||||
if (account.scenario === "employer") {
|
||||
return account.onboarding_step === "completed" ? paths.employer.root : paths.employer.company;
|
||||
}
|
||||
|
||||
switch (account.onboarding_step) {
|
||||
case "candidate_consents":
|
||||
case "candidate_questionnaire":
|
||||
return paths.candidate.onboarding;
|
||||
case "candidate_profile":
|
||||
return paths.candidate.profile;
|
||||
case "candidate_assessment":
|
||||
return paths.candidate.assessment;
|
||||
case "employer_company":
|
||||
return paths.candidate.onboarding;
|
||||
case "completed":
|
||||
return paths.candidate.root;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user