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

feat: profile app #34

Merged
merged 5 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ workflows:
only:
- dev
- challenge-listing-part-1
- feat/profile-app

# Production builds are exectuted only on tagged commits to the
# master branch.
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ dist

# VS Code settings
.vscode/

# Webstorm setttings
.idea/
1 change: 1 addition & 0 deletions config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
},
API: {
V3: "https://api.topcoder-dev.com/v3",
V5: "https://api.topcoder-dev.com/v5",
},
REAUTH_OFFSET: 55, // seconds
};
70 changes: 36 additions & 34 deletions src/components/AllAppsMenu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,43 @@ const AllAppsMenu = () => {
<div className="all-apps-menu-popover-content">
<div className="all-apps-menu-list-title">SWITCH TOOLS</div>
<ul className="all-apps-menu-list">
{menu.map((appCategory) => (
<Fragment>
<div className="switch-category-title">
<div className="menu-divider"></div>
<div className="all-apps-menu-category-name">
{appCategory.category}
{menu
.filter((appCategory) => !appCategory.hidden)
.map((appCategory) => (
<Fragment>
<div className="switch-category-title">
<div className="menu-divider"></div>
<div className="all-apps-menu-category-name">
{appCategory.category}
</div>
<div className="menu-divider"></div>
</div>
<div className="menu-divider"></div>
</div>
{appCategory.apps.map((app) => {
// if app is roles restricted check for access
if (app.roles) {
// not logged-in
if (!auth || !tokenData) return null;
// roles in v3 token match?
if (
tokenData &&
!intersection(app.roles, tokenData.roles).length
)
return null;
}
return (
<li className="all-apps-menu-app" key={app.path}>
<Link
to={app.path}
onClick={(e) => closeMenu(e, app)}
>
<img src={app.icon} alt={`${app.title} Icon`} />
<span>{app.title}</span>
</Link>
</li>
);
})}
</Fragment>
))}
{appCategory.apps.map((app) => {
// if app is roles restricted check for access
if (app.roles) {
// not logged-in
if (!auth || !tokenData) return null;
// roles in v3 token match?
if (
tokenData &&
!intersection(app.roles, tokenData.roles).length
)
return null;
}
return (
<li className="all-apps-menu-app" key={app.path}>
<Link
to={app.path}
onClick={(e) => closeMenu(e, app)}
>
<img src={app.icon} alt={`${app.title} Icon`} />
<span>{app.title}</span>
</Link>
</li>
);
})}
</Fragment>
))}
</ul>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/components/UserMenu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Shows logged-in user with user menu with options like log-out.
*/
import React, { useState, useCallback, Fragment } from "react";
import { Link } from "@reach/router";
import Avatar from "../Avatar";
import cn from "classnames";
import OutsideClickHandler from "react-outside-click-handler";
Expand Down Expand Up @@ -62,6 +63,11 @@ const UserMenu = ({ profile }) => {
<div className="user-menu-popover-arrow" />
<div className="user-menu-popover-content">
<ul className="user-menu-list">
<li>
<Link to={`/profile/${profile.handle}`} onClick={closeMenu}>
Profile
</Link>
</li>
<li>
<a href={getLogoutUrl()} onClick={onLogoutClick}>
Log Out
Expand Down
12 changes: 12 additions & 0 deletions src/constants/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,16 @@ export const APP_CATEGORIES = [
},
],
},
{
category: "Profile",
hidden: true,
apps: [
{
title: "Profile App",
path: "/profile/",
isExact: false,
menu: [],
},
],
},
];
4 changes: 2 additions & 2 deletions src/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ const loadProfile = (userTokenV3) => {
if (!userTokenV3) return Promise.resolve(null);
const user = decodeToken(userTokenV3);
const fetcher = getFetcher(userTokenV3);
return fetcher(`${config.API.V3}/members/${user.handle}`, {
return fetcher(`${config.API.V5}/members/${user.handle}`, {
method: "get",
})
.then((res) => res.json())
.then((res) => (res.result.status === 200 ? res.result.content : {}));
.then((res) => res || {});
};

configureConnector({
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = (webpackConfigEnv, options) => {
rules: [
{
/* Loads svg images. */
test: /[/\/]assets[/\/]images[/\/].+\.svg$/,
test: /[/\\]assets[/\\]images[/\\].+\.svg$/,
exclude: /node_modules/,
loader: "file-loader",
options: {
Expand Down