Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 651ec30

Browse files
authored
Merge pull request #57 from topcoder-platform/feat/skip-onboarding
feat: skip onboarding
2 parents 9295e4b + 35d29ac commit 651ec30

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/utils/index.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,30 @@ export const businessLogin = () => {
5757
*/
5858
export function checkOnboarding(resp) {
5959
if (resp?.data.length === 0) {
60-
return false;
60+
return "/onboard/";
6161
}
62-
const data = resp?.data.filter(
62+
63+
const onboardingChecklistTrait = resp?.data.filter(
6364
(item) => item.traitId === "onboarding_checklist"
64-
)[0].traits.data[0].profile_completed;
65-
if (data.status === "completed") {
65+
)[0].traits;
66+
67+
// Check if onboarding flow needs to be skipped
68+
if (
69+
onboardingChecklistTrait.data[0].skip_onboarding &&
70+
onboardingChecklistTrait.data[0].skip_onboarding.value === true
71+
) {
72+
return false;
73+
}
74+
75+
const profileCompletedData =
76+
onboardingChecklistTrait.data[0].profile_completed;
77+
78+
if (profileCompletedData.status === "completed") {
6679
return false;
6780
}
6881

69-
for (const item in data.metadata) {
70-
if (data.metadata[item]) {
82+
for (const item in profileCompletedData.metadata) {
83+
if (profileCompletedData.metadata[item]) {
7184
return false;
7285
}
7386
}
@@ -78,11 +91,12 @@ export function checkOnboarding(resp) {
7891
"/onboard/payments-setup": [],
7992
"/onboard/build-my-profile": ["bio", "work", "education", "language"],
8093
};
81-
if (data.status === "pending_at_user") {
82-
const flags = Object.keys(data.metadata);
94+
95+
if (profileCompletedData.status === "pending_at_user") {
96+
const flags = Object.keys(profileCompletedData.metadata);
8397
for (const step of Object.keys(steps)) {
8498
for (const flag of steps[step]) {
85-
if (flags.indexOf(flag) >= 0 && !data.metadata[flag]) {
99+
if (flags.indexOf(flag) >= 0 && !profileCompletedData.metadata[flag]) {
86100
return step;
87101
}
88102
}

0 commit comments

Comments
 (0)