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

fix: check to decide if to show onboarding wizard #60

Merged
merged 1 commit into from
Jan 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash';
import _ from "lodash";
import moment from "moment";
import config from "../../config";

Expand Down Expand Up @@ -57,21 +57,29 @@ export const businessLogin = () => {
*/
export function checkOnboarding(resp) {
if (resp?.data.length === 0) {
// return "/onboard/";
return false;
return "/onboard/";
}

const onboardingChecklistTrait = resp?.data.filter(
(item) => item.traitId === "onboarding_checklist"
)[0].traits;

// // Check if onboarding flow needs to be skipped
// if (
// onboardingChecklistTrait.data[0].skip_onboarding &&
// onboardingChecklistTrait.data[0].skip_onboarding.value === true
// ) {
// return false;
// }
// 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;
Expand Down