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

Commit 67dfe41

Browse files
authored
Merge pull request #61 from topcoder-platform/refactor/remove-onboard-checklist-check
refactor: remove onboard checklist check
2 parents 5dc65a4 + f6a64e3 commit 67dfe41

File tree

3 files changed

+0
-96
lines changed

3 files changed

+0
-96
lines changed

src/App.jsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { useSelector } from "react-redux";
1010
import useMatchSomeRoute from "./hooks/useMatchSomeRoute";
1111
import NotificationsModal from "./components/NotificationsModal";
1212
import "./styles/main.module.scss";
13-
import { checkOnboarding, checkProfileCreationDate } from "./utils";
14-
import { getOnboardingChecklist } from "./services/auth";
1513

1614
const App = () => {
1715
// all menu options
@@ -50,23 +48,6 @@ const App = () => {
5048
}
5149
}, [isSideBarDisabled]);
5250

53-
useEffect(() => {
54-
(async () => {
55-
if (auth?.profile && checkProfileCreationDate(auth?.profile)) {
56-
const { profile, tokenV3 } = auth;
57-
58-
const response = await getOnboardingChecklist(profile?.handle, tokenV3);
59-
const onboardingPath = checkOnboarding(response);
60-
if (onboardingPath) {
61-
setHideSwitchTools(true);
62-
navigate(onboardingPath);
63-
} else {
64-
setHideSwitchTools(false);
65-
}
66-
}
67-
})();
68-
}, [auth]);
69-
7051
return (
7152
<>
7253
<NavBar hideSwitchTools={hideSwitchTools} />

src/services/auth.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,3 @@ export function authenticate(store) {
126126
});
127127
}
128128

129-
/**
130-
* Get the onboarding checklist data to know completed steps
131-
*/
132-
export function getOnboardingChecklist(username, userTokenV3) {
133-
const fetcher = getFetcher(userTokenV3);
134-
return fetcher(
135-
`${config.API.V5}/members/${username}/traits?traitIds=onboarding_checklist`
136-
)
137-
.then((res) => res.json())
138-
.then((res) => ({ data: res || [] }));
139-
}

src/utils/index.js

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -48,72 +48,6 @@ export const businessLogin = () => {
4848
window.location = getBusinessLoginUrl();
4949
};
5050

51-
/**
52-
* Check Onboarding API
53-
*
54-
* @param resp {Object} User trait object
55-
*
56-
* @returns {boolean | string}
57-
*/
58-
export function checkOnboarding(resp) {
59-
if (resp?.data.length === 0) {
60-
return "/onboard/";
61-
}
62-
63-
const onboardingChecklistTrait = resp?.data.filter(
64-
(item) => item.traitId === "onboarding_checklist"
65-
)[0].traits;
66-
67-
// Check if onboarding flow needs to be skipped
68-
// 1. if the trait onboarding_wizard has a valid value for status.
69-
// possible values of status are [seeen, completed]. Since we only want to show
70-
// the onboarding wizard to users who haven't at least once seen the wizard
71-
// it is sufficient to check for a non null value.
72-
// 2. if the trait onboarding_wizard has a truthy value for skip.
73-
74-
for (let checklistTrait of onboardingChecklistTrait.data) {
75-
if (
76-
checklistTrait.onboarding_wizard != null &&
77-
(checklistTrait.onboarding_wizard.status != null ||
78-
checklistTrait.onboarding_wizard.skip)
79-
) {
80-
return false;
81-
}
82-
}
83-
84-
const profileCompletedData =
85-
onboardingChecklistTrait.data[0].profile_completed;
86-
87-
if (profileCompletedData.status === "completed") {
88-
return false;
89-
}
90-
91-
for (const item in profileCompletedData.metadata) {
92-
if (profileCompletedData.metadata[item]) {
93-
return false;
94-
}
95-
}
96-
97-
const steps = {
98-
"/onboard/": ["profile_picture", "skills"],
99-
"/onboard/contact-details": ["country"],
100-
"/onboard/payments-setup": [],
101-
"/onboard/build-my-profile": ["bio", "work", "education", "language"],
102-
};
103-
104-
if (profileCompletedData.status === "pending_at_user") {
105-
const flags = Object.keys(profileCompletedData.metadata);
106-
for (const step of Object.keys(steps)) {
107-
for (const flag of steps[step]) {
108-
if (flags.indexOf(flag) >= 0 && !profileCompletedData.metadata[flag]) {
109-
return step;
110-
}
111-
}
112-
}
113-
}
114-
return false;
115-
}
116-
11751
/**
11852
* Checks If current user's profile creation time
11953
*

0 commit comments

Comments
 (0)