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

Commit 8b32a61

Browse files
committed
Merge branch 'dev'
Signed-off-by: Rakib Ansary <[email protected]>
2 parents 4a3db2f + 5c759ce commit 8b32a61

File tree

13 files changed

+92
-18
lines changed

13 files changed

+92
-18
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ workflows:
7474
branches:
7575
only:
7676
- dev
77-
- challenge-listing-part-1
78-
- feat/profile-app
77+
- feat/onboarding-app
7978

8079
# Production builds are exectuted only on tagged commits to the
8180
# master branch.

config/dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ module.exports = {
1212
V5: "https://api.topcoder-dev.com/v5",
1313
},
1414
REAUTH_OFFSET: 55, // seconds
15+
PROFILE_CREATION_DATE_THRESHOLD: "2021-10-25", // format: "YYYY-MM-DD"
1516
};

src/App.jsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +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 { 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 { checkOnboardingPath } from "./utils";
1314

1415
const App = () => {
1516
// all menu options
@@ -18,10 +19,14 @@ const App = () => {
1819
const apps = useMemo(() => _.flatMap(menu, "apps"), [menu]);
1920
// list of routes where we have to disabled sidebar
2021
const disabledRoutes = useSelector((state) => state.menu.disabledRoutes);
22+
// user profile information
23+
const auth = useSelector((state) => state.auth);
2124
// `true` is sidebar has to be disabled for the current route
2225
const isSideBarDisabled = useMatchSomeRoute(disabledRoutes);
2326
// Left sidebar collapse state
2427
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
28+
// hide switch tools and notification when user is onboarding
29+
const [hideSwitchTools, setHideSwitchTools] = useState(false);
2530
// Toggle left sidebar callback
2631
const toggleSidebar = useCallback(() => {
2732
setSidebarCollapsed(!sidebarCollapsed);
@@ -33,6 +38,7 @@ const App = () => {
3338
(!state.notifications.initialized &&
3439
!state.notifications.communityInitialized)
3540
);
41+
const location = useLocation();
3642

3743
// set/remove class for the whole page, to know if sidebar is present or no
3844
useEffect(() => {
@@ -43,9 +49,17 @@ const App = () => {
4349
}
4450
}, [isSideBarDisabled]);
4551

52+
useEffect(() => {
53+
if (matchPath("onboard/*", location.pathname)) {
54+
setHideSwitchTools(true);
55+
} else {
56+
setHideSwitchTools(false);
57+
}
58+
}, [location]);
59+
4660
return (
4761
<>
48-
<NavBar />
62+
<NavBar hideSwitchTools={hideSwitchTools} />
4963
{!isSideBarDisabled && (
5064
<div className="main-menu-wrapper">
5165
<Router>

src/actions/auth.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export default {
55
type: ACTIONS.AUTH.LOAD_PROFILE,
66
payload: profile,
77
}),
8+
setProfilePhoto: (photoURL) => ({
9+
type: ACTIONS.AUTH.SET_PROFILE_PHOTO,
10+
payload: photoURL,
11+
}),
812
setTcTokenV3: (tokenV3) => ({
913
type: ACTIONS.AUTH.SET_TOKEN_V3,
1014
payload: tokenV3,

src/components/NavBar/index.jsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import React, {
1111
useMemo,
1212
} from "react";
1313
import _ from "lodash";
14+
import PropTypes from "prop-types";
1415
import UserMenu from "../UserMenu";
1516
import AllAppsMenu from "../AllAppsMenu";
1617
import { useSelector } from "react-redux";
@@ -21,7 +22,7 @@ import "./styles.css";
2122
import { useMediaQuery } from "react-responsive";
2223
import NotificationsMenu from "../NotificationsMenu";
2324

24-
const NavBar = () => {
25+
const NavBar = ({ hideSwitchTools }) => {
2526
// all menu options
2627
const menu = useSelector((state) => state.menu.categories);
2728
// flat list of all apps
@@ -54,7 +55,9 @@ const NavBar = () => {
5455
<div className="navbar">
5556
<div className="navbar-left">
5657
{isMobile ? (
57-
<AllAppsMenu />
58+
hideSwitchTools ? null : (
59+
<AllAppsMenu />
60+
)
5861
) : (
5962
<Fragment>
6063
<Link to="/">
@@ -88,8 +91,11 @@ const NavBar = () => {
8891
(auth.tokenV3 ? (
8992
auth.profile && (
9093
<Fragment>
91-
<NotificationsMenu />
92-
<UserMenu profile={auth.profile} />
94+
{hideSwitchTools ? null : <NotificationsMenu />}
95+
<UserMenu
96+
profile={auth.profile}
97+
hideSwitchTools={hideSwitchTools}
98+
/>
9399
</Fragment>
94100
)
95101
) : (
@@ -100,14 +106,17 @@ const NavBar = () => {
100106
</Fragment>
101107
) : (
102108
<Fragment>
103-
<AllAppsMenu appChange={changeApp} />
109+
{hideSwitchTools ? null : <AllAppsMenu appChange={changeApp} />}
104110
<div className="navbar-divider"></div>
105111
{auth.isInitialized &&
106112
(auth.tokenV3 ? (
107113
auth.profile && (
108114
<Fragment>
109-
<NotificationsMenu />
110-
<UserMenu profile={auth.profile} />
115+
{hideSwitchTools ? null : <NotificationsMenu />}
116+
<UserMenu
117+
profile={auth.profile}
118+
hideSwitchTools={hideSwitchTools}
119+
/>
111120
</Fragment>
112121
)
113122
) : (
@@ -122,4 +131,12 @@ const NavBar = () => {
122131
);
123132
};
124133

134+
NavBar.defaultProps = {
135+
hideSwitchTools: false,
136+
};
137+
138+
NavBar.propTypes = {
139+
hideSwitchTools: PropTypes.boolean,
140+
};
141+
125142
export default NavBar;

src/components/UserMenu/index.jsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
*/
66
import React, { useState, useCallback, Fragment } from "react";
77
import { Link } from "@reach/router";
8+
import PropTypes from "prop-types";
89
import Avatar from "../Avatar";
910
import cn from "classnames";
1011
import OutsideClickHandler from "react-outside-click-handler";
1112
import { logout, getLogoutUrl } from "../../utils";
1213
import "./styles.css";
1314
import { useMediaQuery } from "react-responsive";
1415

15-
const UserMenu = ({ profile }) => {
16+
const UserMenu = ({ profile, hideSwitchTools }) => {
1617
const [isOpenMenu, setIsOpenMenu] = useState(false);
1718

1819
const closeMenu = useCallback(() => {
@@ -63,11 +64,16 @@ const UserMenu = ({ profile }) => {
6364
<div className="user-menu-popover-arrow" />
6465
<div className="user-menu-popover-content">
6566
<ul className="user-menu-list">
66-
<li>
67-
<Link to={`/profile/${profile.handle}`} onClick={closeMenu}>
68-
Profile
69-
</Link>
70-
</li>
67+
{hideSwitchTools ? null : (
68+
<li>
69+
<Link
70+
to={`/profile/${profile.handle}`}
71+
onClick={closeMenu}
72+
>
73+
Profile
74+
</Link>
75+
</li>
76+
)}
7177
<li>
7278
<a href={getLogoutUrl()} onClick={onLogoutClick}>
7379
Log Out
@@ -83,4 +89,12 @@ const UserMenu = ({ profile }) => {
8389
);
8490
};
8591

92+
UserMenu.defaultProps = {
93+
hideSwitchTools: false,
94+
};
95+
96+
UserMenu.propTypes = {
97+
hideSwitchTools: PropTypes.boolean,
98+
};
99+
86100
export default UserMenu;

src/constants/apps.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,16 @@ export const APP_CATEGORIES = [
8383
},
8484
],
8585
},
86+
{
87+
category: "Onboard",
88+
hidden: true,
89+
apps: [
90+
{
91+
title: "Member Onboarding",
92+
path: "/onboard",
93+
isExact: false,
94+
menu: [],
95+
},
96+
],
97+
},
8698
];

src/constants/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { APP_CATEGORIES };
77
export const ACTIONS = {
88
AUTH: {
99
LOAD_PROFILE: "LOAD_PROFILE",
10+
SET_PROFILE_PHOTO: "SET_PROFILE_PHOTO",
1011
SET_TOKEN_V3: "SET_TOKEN_V3",
1112
SET_TOKEN_V2: "SET_TOKEN_V2",
1213
SET_INITIALIZED: "SET_INITIALIZED",

src/reducers/auth.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const authReducer = (state = initialState, action) => {
2929
profile: action.payload,
3030
isProfileLoaded: true,
3131
};
32+
case ACTIONS.AUTH.SET_PROFILE_PHOTO:
33+
return state.profile ? ({
34+
...state,
35+
profile: {...state.profile, photoURL: action.payload},
36+
}) : state;
3237
case ACTIONS.AUTH.SET_INITIALIZED:
3338
return {
3439
...state,

src/topcoder-micro-frontends-navbar-app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
enableSidebarForRoute,
1717
getAuthUserTokens,
1818
getAuthUserProfile,
19+
setUserProfilePhoto,
1920
setNotificationPlatform,
2021
} from "./utils/exports";
2122

@@ -42,6 +43,7 @@ export {
4243
setAppMenu,
4344
getAuthUserTokens,
4445
getAuthUserProfile,
46+
setUserProfilePhoto,
4547
disableSidebarForRoute,
4648
enableSidebarForRoute,
4749
setNotificationPlatform,

src/utils/exports.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import _ from "lodash";
77
import { bindActionCreators } from "redux";
88
import store from "../store";
99
import menuActions from "../actions/menu";
10+
import authActions from "../actions/auth";
1011
import notificationActions from "../actions/notifications";
1112

1213
// bind all the actions for exporting here
@@ -15,12 +16,14 @@ export const {
1516
disableSidebarForRoute,
1617
enableSidebarForRoute,
1718
setNotificationPlatform,
19+
setUserProfilePhoto
1820
} = bindActionCreators(
1921
{
2022
setAppMenu: menuActions.setAppMenu,
2123
disableSidebarForRoute: menuActions.disableSidebarForRoute,
2224
enableSidebarForRoute: menuActions.enableSidebarForRoute,
2325
setNotificationPlatform: notificationActions.setNotificationPlatform,
26+
setUserProfilePhoto: authActions.setProfilePhoto,
2427
},
2528
store.dispatch
2629
);

src/utils/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import _ from 'lodash';
2+
import moment from "moment";
13
import config from "../../config";
24

35
/**

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = (webpackConfigEnv, options) => {
3434
rules: [
3535
{
3636
/* Loads svg images. */
37-
test: /[/\\]assets[/\\]images[/\\].+\.svg$/,
37+
test: /[/\/\\]assets[/\/\\]images[/\/\\].+\.svg$/,
3838
exclude: /node_modules/,
3939
loader: "file-loader",
4040
options: {

0 commit comments

Comments
 (0)