diff --git a/src/hoc/withAuthentication/index.js b/src/hoc/withAuthentication/index.js index b0234bb..8f71d5d 100644 --- a/src/hoc/withAuthentication/index.js +++ b/src/hoc/withAuthentication/index.js @@ -42,7 +42,13 @@ export default function withAuthentication(Component) { status: "seen", }, }); - + updateOnboardingWizardTraits(handle, traits, shouldCreate); + } else if ( + traits[onboardingWizardChecklistIndex].onboarding_wizard?.status === + "pending_at_user" + ) { + traits[onboardingWizardChecklistIndex].onboarding_wizard.status = + "seen"; updateOnboardingWizardTraits(handle, traits, shouldCreate); } }); diff --git a/src/root.component.jsx b/src/root.component.jsx index 2dca66f..5359cf2 100644 --- a/src/root.component.jsx +++ b/src/root.component.jsx @@ -31,7 +31,7 @@ if (HEAP_ANALYTICS_KEY) { export default function Root() { useEffect(() => { disableNavigationForRoute("/onboard/*"); - + disableSidebarForRoute("/onboard"); disableSidebarForRoute("/onboard/contact-details"); disableSidebarForRoute("/onboard/payment-setup"); diff --git a/src/routes/BuildMyProfile/index.jsx b/src/routes/BuildMyProfile/index.jsx index 354f914..0cd4260 100644 --- a/src/routes/BuildMyProfile/index.jsx +++ b/src/routes/BuildMyProfile/index.jsx @@ -47,6 +47,8 @@ import moment from "moment"; import _ from "lodash"; import { createTraits, updateTraits } from "services/traits"; import { updateMemberData } from "services/memberData"; +import { getCookie } from "utils/"; +import { updateOnboardingWizardTraits } from "services/onboardingChecklist"; const formatDate = (date) => { let ret = new Date( @@ -61,6 +63,9 @@ const BuildMyProfile = () => { const [isLoading, setIsLoading] = useState(false); const [myProfileData, setMyProfileData] = useState({}); const [bio, setBio] = useState(""); + const [redirectUrl, setRedirectUrl] = useState( + config.TOPCODER_COMMUNITY_WEBSITE_URL + "/home" + ); // form states const [formData, setFormData] = useState({ @@ -189,6 +194,7 @@ const BuildMyProfile = () => { // Get Member data from redux (firstName, lastName, handle, photoURL) and store it on myProfileData useEffect(() => { if (!authUser || !authUser.handle) return; + getAuthUserProfile() .then((result) => { setMyProfileData(result); @@ -209,6 +215,9 @@ const BuildMyProfile = () => { // find datas we need // get traits values let traits = result?.data; + const onboardingChecklist = traits.find( + (t) => t.traitId === "onboarding_checklist" + ); let basicInfo = traits.find((t) => t.traitId === "basic_info"); let workExp = traits.find((t) => t.traitId === "work"); let educationExp = traits.find((t) => t.traitId === "education"); @@ -218,6 +227,24 @@ const BuildMyProfile = () => { let educationExpValue = educationExp?.traits?.data; let languagesExpValue = languagesExp?.traits?.data; + if ( + onboardingChecklist.traits.data.length > 0 && + onboardingChecklist.traits.data[0].onboarding_wizard?.status !== + "completed" + ) { + onboardingChecklist.traits.data[0].onboarding_wizard.status = + "completed"; + const url = getCookie("returnAfterOnboard"); + if (url != null) { + setRedirectUrl(url); + } + updateOnboardingWizardTraits( + authUser.handle, + onboardingChecklist.traits.data, + false + ); + } + // fill title and bio to state if (basicInfoValue) { // Using shortBio as title has to do with v3 using this mapping @@ -535,7 +562,7 @@ const BuildMyProfile = () => { } setIsLoading(false); - window.location.href = config.TOPCODER_COMMUNITY_WEBSITE_URL + "/home"; + window.location.href = redirectUrl; }; return ( @@ -1018,11 +1045,7 @@ const BuildMyProfile = () => { handleSubmit(e)} >