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

Commit a682676

Browse files
authored
Merge pull request #44 from nursoltan-s/disable-redirection
disable redirection
2 parents ac22d0e + 41ed7da commit a682676

File tree

3 files changed

+9
-97
lines changed

3 files changed

+9
-97
lines changed

src/App.jsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import React, { useState, useCallback, useMemo, useEffect } from "react";
55
import _ from "lodash";
66
import MainMenu from "./components/MainMenu";
77
import NavBar from "./components/NavBar";
8-
import { navigate, Router } from "@reach/router";
8+
import { matchPath, Router, useLocation } from "@reach/router";
99
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";
13+
import { checkOnboardingPath } from "./utils";
1514

1615
const App = () => {
1716
// all menu options
@@ -39,6 +38,7 @@ const App = () => {
3938
(!state.notifications.initialized &&
4039
!state.notifications.communityInitialized)
4140
);
41+
const location = useLocation();
4242

4343
// set/remove class for the whole page, to know if sidebar is present or no
4444
useEffect(() => {
@@ -50,21 +50,12 @@ const App = () => {
5050
}, [isSideBarDisabled]);
5151

5252
useEffect(() => {
53-
(async () => {
54-
if (auth?.profile && checkProfileCreationDate(auth?.profile)) {
55-
const { profile, tokenV3 } = auth;
56-
57-
const response = await getOnboardingChecklist(profile?.handle, tokenV3);
58-
const onboardingPath = checkOnboarding(response);
59-
if (onboardingPath) {
60-
setHideSwitchTools(true);
61-
navigate(onboardingPath);
62-
} else {
63-
setHideSwitchTools(false);
64-
}
65-
}
66-
})();
67-
}, [auth]);
53+
if (matchPath("onboard/*", location.pathname)) {
54+
setHideSwitchTools(true);
55+
} else {
56+
setHideSwitchTools(false);
57+
}
58+
}, [location]);
6859

6960
return (
7061
<>

src/services/auth.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,3 @@ export function authenticate(store) {
125125
}
126126
});
127127
}
128-
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 & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -47,70 +47,3 @@ export const login = () => {
4747
export const businessLogin = () => {
4848
window.location = getBusinessLoginUrl();
4949
};
50-
51-
/**
52-
* TODO: Re-check when onboarding processor is ready
53-
* Check Onboarding API
54-
*
55-
* @param resp {Object} User trait object
56-
*
57-
* @returns {boolean | string}
58-
*/
59-
export function checkOnboarding(resp) {
60-
if (resp?.data.length === 0) {
61-
return "/onboard/";
62-
}
63-
const data = resp?.data.filter(
64-
(item) => item.traitId === "onboarding_checklist"
65-
)[0].traits.data[0].profile_completed;
66-
if (data.status === "completed") {
67-
return false;
68-
}
69-
70-
// TODO: Re-check when onboarding processor is ready.
71-
// It checks for at least one onboarding checklist was completed, then we don't enter onboarding flow
72-
// This logic will be changed.
73-
for (const item in data.metadata) {
74-
if (data.metadata[item]) {
75-
return false;
76-
}
77-
}
78-
79-
const steps = {
80-
"/onboard/": ["profile_picture", "skills"],
81-
"/onboard/contact-details": ["country"],
82-
"/onboard/payments-setup": [],
83-
"/onboard/build-my-profile": ["bio", "work", "education", "language"],
84-
};
85-
if (data.status === "pending_at_user") {
86-
const flags = Object.keys(data.metadata);
87-
for (const step of Object.keys(steps)) {
88-
for (const flag of steps[step]) {
89-
if (flags.indexOf(flag) >= 0 && !data.metadata[flag]) {
90-
return step;
91-
}
92-
}
93-
}
94-
}
95-
return false;
96-
}
97-
98-
/**
99-
* Checks If current user's profile creation time
100-
*
101-
* @param profile {Object} user profile
102-
*
103-
* @returns {boolean}
104-
*/
105-
export const checkProfileCreationDate = (profile) => {
106-
const thresholdDate = moment(
107-
config.PROFILE_CREATION_DATE_THRESHOLD,
108-
"YYYY-MM-DD"
109-
);
110-
111-
if (profile?.createdAt) {
112-
return thresholdDate.isBefore(moment(profile?.createdAt));
113-
}
114-
115-
return false;
116-
};

0 commit comments

Comments
 (0)