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

[Ready Release] Gigs Listing - RCRM Status Sync #200

Merged
merged 14 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ workflows:
branches:
only:
- dev
- challenge-details-page

# Production builds are exectuted only on tagged commits to the
# master branch.
Expand Down
6 changes: 4 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ require("dotenv").config();

module.exports = {
MFE_CONFIG: {
'@topcoder/micro-frontends-challenges-app': 'https://platform.topcoder-dev.com/challenges-app/topcoder-micro-frontends-challenges-app.js',
'@topcoder/micro-frontends-gigs-app': 'https://platform.topcoder-dev.com/gigs-app/topcoder-micro-frontends-gigs-app.js',
"@topcoder/micro-frontends-challenges-app":
"https://platform.topcoder-dev.com/challenges-app/topcoder-micro-frontends-challenges-app.js",
"@topcoder/micro-frontends-gigs-app":
"https://platform.topcoder-dev.com/gigs-app/topcoder-micro-frontends-gigs-app.js",
}
};
9 changes: 8 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Main App component
*/
import React, { useLayoutEffect, useEffect, useRef } from "react";
import { Router, useLocation } from "@reach/router";
import { Router, useLocation, Redirect } from "@reach/router";
import { disableSidebarForRoute } from "@topcoder/micro-frontends-navbar-app";
import _ from "lodash";
import { usePreviousLocation } from "./utils/hooks";
Expand Down Expand Up @@ -45,10 +45,17 @@ const App = () => {
System.import("@topcoder/micro-frontends-challenges-app")
}
/>
<Parcel
path="/earn/gigs"
view="gigs"
config={() => System.import("@topcoder/micro-frontends-gigs-app")}
/>
<Parcel
path="/earn/my-gigs"
view="my-gigs"
config={() => System.import("@topcoder/micro-frontends-gigs-app")}
/>
<Redirect from="/earn/*" to="/earn/find/challenges/" noThrow />
</Router>
</>
);
Expand Down
6 changes: 3 additions & 3 deletions src/actions/menu.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createActions } from "redux-actions";

function showMenu(visible) {
return visible
return visible;
}

export default createActions({
SHOW_MENU: showMenu
})
SHOW_MENU: showMenu,
});
3 changes: 2 additions & 1 deletion src/components/FeedbackButton/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import "./styles.scss";

const FeedbackButton = () => (
const FeedbackButton = ({ className }) => (
<a
className={className}
styleName="feedback-button"
href="https://discussions.topcoder.com/discussion/8870/new-beta-site-discuss?new=1"
target="_blank"
Expand Down
11 changes: 8 additions & 3 deletions src/components/Menu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import PT from "prop-types";
import _ from "lodash";
import * as utils from "../../utils";
import IconChevronUp from "assets/icons/menu-chevron-up.svg";
import { navigate } from '@reach/router'
import { navigate } from "@reach/router";

import "./styles.scss";

const Menu = ({ menu, selected, onSelect, isLoggedIn, onUpdateMenu }) => {
const selectionRef = useRef();
if (!selectionRef.current) {
selectionRef.current = new utils.menu.MenuSelection(_.cloneDeep(menu), selected, onSelect, onUpdateMenu)
selectionRef.current = new utils.menu.MenuSelection(
_.cloneDeep(menu),
selected,
onSelect,
onUpdateMenu
);
}

useEffect(() => {
selectionRef.current.setMenu(menu);
}, [menu])
}, [menu]);

useEffect(() => {
selectionRef.current.select(selected);
Expand Down
8 changes: 4 additions & 4 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export const NAV_MENU = {
iconActive: "find-work-green.svg",
children: [
{
name: "Challenges",
path: "/earn/find/challenges",
name: "Gigs",
path: "/earn/gigs",
},
{
name: "Gigs",
path: "",
name: "Challenges",
path: "/earn/find/challenges",
},
],
},
Expand Down
15 changes: 6 additions & 9 deletions src/containers/Menu/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import Menu from '../../components/Menu';
import * as utils from '../../utils';
import * as constants from '../../constants';
import Menu from "../../components/Menu";
import * as utils from "../../utils";
import * as constants from "../../constants";
import { useLocation } from "@reach/router";

const MenuContainer = () => {
Expand All @@ -14,7 +14,7 @@ const MenuContainer = () => {
useEffect(() => {
const checkIsLoggedIn = async () => {
setIsLoggedIn(await utils.auth.isLoggedIn());
}
};
checkIsLoggedIn();
}, []);

Expand All @@ -37,17 +37,14 @@ const MenuContainer = () => {
selected={selectedMenuItemName}
onSelect={(name) => {
setSelectedMenuItemName(name);
if (name == "Gigs") {
window.location.href = `${process.env.URL.BASE}/gigs`;
}
}}
isLoggedIn={isLoggedIn}
onUpdateMenu={(menu) => {
const change = { ...menu };
saveMenu(change);
}}
/>
)
}
);
};

export default MenuContainer;
2 changes: 1 addition & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { combineReducers } from "redux";
import menu from './menu';
import menu from "./menu";

export default combineReducers({
menu,
Expand Down
17 changes: 10 additions & 7 deletions src/reducers/menu.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { handleActions } from "redux-actions";

const defaultState = {
show: false
}
show: false,
};

function onShowMenu(state, { payload }) {
return {
...state,
show: payload
}
show: payload,
};
}

export default handleActions({
SHOW_MENU: onShowMenu
}, defaultState)
export default handleActions(
{
SHOW_MENU: onShowMenu,
},
defaultState
);
17 changes: 12 additions & 5 deletions src/set-public-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ import { setPublicPath } from "systemjs-webpack-interop";

setPublicPath("@topcoder/micro-frontends-earn-app");

const challengesAppUrl = process.env.MFE_CONFIG['@topcoder/micro-frontends-challenges-app']
const gigsAppUrl = process.env.MFE_CONFIG['@topcoder/micro-frontends-gigs-app']
const challengesAppUrl =
process.env.MFE_CONFIG["@topcoder/micro-frontends-challenges-app"];
const gigsAppUrl = process.env.MFE_CONFIG["@topcoder/micro-frontends-gigs-app"];

importMapOverrides.resetOverrides()
importMapOverrides.addOverride('@topcoder/micro-frontends-challenges-app', challengesAppUrl)
importMapOverrides.addOverride('@topcoder/micro-frontends-gigs-app', gigsAppUrl)
importMapOverrides.resetOverrides();
importMapOverrides.addOverride(
"@topcoder/micro-frontends-challenges-app",
challengesAppUrl
);
importMapOverrides.addOverride(
"@topcoder/micro-frontends-gigs-app",
gigsAppUrl
);
7 changes: 5 additions & 2 deletions src/topcoder-micro-frontends-earn-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { bindActionCreators } from "redux";
import Root from "./root.component";
import Banner from "./components/Banner";
import FeedbackButton from "./components/FeedbackButton";
import actions from "./actions/menu"
import actions from "./actions/menu";
import store from "./store";

const lifecycles = singleSpaReact({
Expand All @@ -26,4 +26,7 @@ const unmount = [lifecycles.unmount];
export { bootstrap, mount, unmount };

export { Banner, FeedbackButton };
export const { showMenu } = bindActionCreators({ showMenu: actions.showMenu }, store.dispatch)
export const { showMenu } = bindActionCreators(
{ showMenu: actions.showMenu },
store.dispatch
);
5 changes: 1 addition & 4 deletions src/utils/auth.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import _ from "lodash";
import {
getAuthUserTokens,
login,
} from "@topcoder/micro-frontends-navbar-app";
import { getAuthUserTokens, login } from "@topcoder/micro-frontends-navbar-app";

export async function isLoggedIn() {
const { tokenV3, tokenV2 } = await getAuthUserTokens();
Expand Down
1 change: 1 addition & 0 deletions src/utils/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class MenuSelection {
if (this.isLeaf(menuItem)) {
menuItem.active = true;
this.selected = menuItem.name;
root.expanded = true;
} else {
menuItem.expanded = !menuItem.expanded;
}
Expand Down