diff --git a/src/App.jsx b/src/App.jsx index 84aa6c0..3cf4fbe 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -10,8 +10,6 @@ import { useSelector } from "react-redux"; import useMatchSomeRoute from "./hooks/useMatchSomeRoute"; import NotificationsModal from "./components/NotificationsModal"; import "./styles/main.module.scss"; -import { checkOnboarding, checkProfileCreationDate } from "./utils"; -import { getOnboardingChecklist } from "./services/auth"; const App = () => { // all menu options @@ -50,23 +48,6 @@ const App = () => { } }, [isSideBarDisabled]); - useEffect(() => { - (async () => { - if (auth?.profile && checkProfileCreationDate(auth?.profile)) { - const { profile, tokenV3 } = auth; - - const response = await getOnboardingChecklist(profile?.handle, tokenV3); - const onboardingPath = checkOnboarding(response); - if (onboardingPath) { - setHideSwitchTools(true); - navigate(onboardingPath); - } else { - setHideSwitchTools(false); - } - } - })(); - }, [auth]); - return ( <> diff --git a/src/services/auth.js b/src/services/auth.js index 59c1613..035f850 100644 --- a/src/services/auth.js +++ b/src/services/auth.js @@ -126,14 +126,3 @@ export function authenticate(store) { }); } -/** - * Get the onboarding checklist data to know completed steps - */ -export function getOnboardingChecklist(username, userTokenV3) { - const fetcher = getFetcher(userTokenV3); - return fetcher( - `${config.API.V5}/members/${username}/traits?traitIds=onboarding_checklist` - ) - .then((res) => res.json()) - .then((res) => ({ data: res || [] })); -} diff --git a/src/utils/index.js b/src/utils/index.js index 4a86808..35ab947 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -48,72 +48,6 @@ export const businessLogin = () => { window.location = getBusinessLoginUrl(); }; -/** - * Check Onboarding API - * - * @param resp {Object} User trait object - * - * @returns {boolean | string} - */ -export function checkOnboarding(resp) { - if (resp?.data.length === 0) { - return "/onboard/"; - } - - const onboardingChecklistTrait = resp?.data.filter( - (item) => item.traitId === "onboarding_checklist" - )[0].traits; - - // Check if onboarding flow needs to be skipped - // 1. if the trait onboarding_wizard has a valid value for status. - // possible values of status are [seeen, completed]. Since we only want to show - // the onboarding wizard to users who haven't at least once seen the wizard - // it is sufficient to check for a non null value. - // 2. if the trait onboarding_wizard has a truthy value for skip. - - for (let checklistTrait of onboardingChecklistTrait.data) { - if ( - checklistTrait.onboarding_wizard != null && - (checklistTrait.onboarding_wizard.status != null || - checklistTrait.onboarding_wizard.skip) - ) { - return false; - } - } - - const profileCompletedData = - onboardingChecklistTrait.data[0].profile_completed; - - if (profileCompletedData.status === "completed") { - return false; - } - - for (const item in profileCompletedData.metadata) { - if (profileCompletedData.metadata[item]) { - return false; - } - } - - const steps = { - "/onboard/": ["profile_picture", "skills"], - "/onboard/contact-details": ["country"], - "/onboard/payments-setup": [], - "/onboard/build-my-profile": ["bio", "work", "education", "language"], - }; - - if (profileCompletedData.status === "pending_at_user") { - const flags = Object.keys(profileCompletedData.metadata); - for (const step of Object.keys(steps)) { - for (const flag of steps[step]) { - if (flags.indexOf(flag) >= 0 && !profileCompletedData.metadata[flag]) { - return step; - } - } - } - } - return false; -} - /** * Checks If current user's profile creation time *