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

Commit 4f8ecfc

Browse files
authored
Merge pull request #188 from topcoder-platform/dev
Challenge details page
2 parents 928039a + 3b9b897 commit 4f8ecfc

File tree

5 files changed

+47
-20
lines changed

5 files changed

+47
-20
lines changed

.circleci/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ workflows:
7777
branches:
7878
only:
7979
- dev
80+
- challenge-details-page
8081

8182
# Production builds are exectuted only on tagged commits to the
8283
# master branch.

README.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ This is a [single-spa](https://single-spa.js.org/) example React microapp.
1818
| `npm start` | Run server which serves production ready build from `dist` folder |
1919
| `npm run dev` | Run app in the `development` mode and `dev` config |
2020
| `npm run dev-https` | Run app in the `development` mode and `dev` config using HTTPS protocol |
21-
| `npm run local` | Run app in the `development` mode and `local-dev` config |
2221
| `npm run prod` | Run app in the `development` mode and `prod` config |
23-
| `npm run build` | Build app for production and puts files to the `dist` folder, default to `development` mode and `local-dev` config |
22+
| `npm run build` | Build app for production and puts files to the `dist` folder, default to `development` mode and `dev` config |
2423
| `npm run analyze` | Analyze dependencies sizes and opens report in the browser |
2524
| `npm run lint` | Check code for lint errors |
2625
| `npm run format` | Format code using prettier |
@@ -33,9 +32,35 @@ This is a [single-spa](https://single-spa.js.org/) example React microapp.
3332
Inside the project folder run:
3433
- `nvm use 10.22.1;` - to use npm version: 10.22.1
3534
- `npm i` - install dependencies
36-
- `npm run local` - run app in `development` mode and `local-dev` config
35+
- `npm run dev` - run app in `development` mode and `dev` config, currently it is using the config from `default.js`
3736
- As this app can be loaded only inside a frame single-spa, you have to run a `micro-frontends-frame` frame app and configure it to use the URL `http://localhost:8008/earn-app/topcoder-micro-frontends-earn-app.js`.
3837

38+
## Local Setup for adding a new MFE
39+
1. The setup is assuming you have setup the `micro-frontends-frame` and `micro-frontends-nav-app`. And this is also assuming your have a new MFE named `another-app` and your local url is `http://localhost:8099/another-app/topcoder-micro-frontends-another-app.js`
40+
41+
2. You have launched existing `micro-frontends-challenges-app` and `micro-frontends-gigs-app` in your local envrionment.
42+
43+
3. Modify the `config/dev.js` by incorporating the module mapping, so it might be look like this if you setup all them in local environment:
44+
45+
```
46+
module.exports = {
47+
MFE_CONFIG: {
48+
'@topcoder/micro-frontends-another-app': 'http://localhost:8099/another-app/topcoder-micro-frontends-another-app.js',
49+
'@topcoder/micro-frontends-challenges-app': 'http://localhost:8009/challenges-app/topcoder-micro-frontends-challenges-app.js',
50+
'@topcoder/micro-frontends-gigs-app': 'http://localhost:8010/gigs-app/topcoder-micro-frontends-gigs-app.js',
51+
}
52+
};
53+
```
54+
4. In the `src/containers/Menu/index.jsx`, you can modify it to add your new `another-app` menu link, challenges-app and gigs-app menu links have already been setup as reference.
55+
56+
5. In the `set-public-path.js` file, add the mapping to your `another-app`, challenges-app and gigs-app have already been setup as the reference.
57+
58+
6. In the `src/App.jsx` file, add the application mount point inside the `<Router>` component, challenges-app and gigs-app have already been setup as the reference
59+
60+
7. Edit your `hosts` file by mapping `127.0.0.1 local.topcoder-dev.com`
61+
62+
8. Now visit `http://local.topcoder-dev.com:8080/earn/find/challenges` to view the `micro-frontends-challenges-app`
63+
3964
## Deployment to Production
4065

4166
- `npm i` - install dependencies

config/local-dev.js

-6
This file was deleted.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"start": "node server.js",
55
"dev": "cross-env APPENV=dev webpack-dev-server",
66
"dev-https": "cross-env APPENV=dev webpack-dev-server --https",
7-
"local": "cross-env APPMODE=local-dev webpack-dev-server --mode=development",
87
"build": "cross-env APPENV=${APPENV:-dev} APPMODE=${APPMODE:-development} webpack --mode=${APPMODE:-development}",
98
"analyze": "cross-env APPMODE=production webpack --mode=production --env.analyze=true",
109
"lint": "eslint src --ext js,jsx --fix",

src/App.jsx

+18-10
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
* Main App component
33
*/
44
import React, { useLayoutEffect, useEffect, useRef } from "react";
5-
import { Router, useLocation, Redirect } from "@reach/router";
5+
import { Router, useLocation } from "@reach/router";
66
import { disableSidebarForRoute } from "@topcoder/micro-frontends-navbar-app";
77
import _ from "lodash";
88
import { usePreviousLocation } from "./utils/hooks";
9-
import Parcel from 'single-spa-react/parcel'
10-
import { useSelector } from 'react-redux'
11-
import ReactDOM from 'react-dom'
9+
import Parcel from "single-spa-react/parcel";
10+
import { useSelector } from "react-redux";
11+
import ReactDOM from "react-dom";
1212

1313
import "./styles/main.scss";
1414

15-
import Menu from './containers/Menu'
15+
import Menu from "./containers/Menu";
1616

1717
const App = () => {
18-
const menuVisible = useSelector(state => state.menu.show)
18+
const menuVisible = useSelector((state) => state.menu.show);
1919

2020
useLayoutEffect(() => {
2121
disableSidebarForRoute("/earn/*");
@@ -36,11 +36,19 @@ const App = () => {
3636

3737
return (
3838
<>
39-
{menuVisible && ReactDOM.createPortal(<Menu />, document.querySelector('#menu-id'))}
39+
{menuVisible &&
40+
ReactDOM.createPortal(<Menu />, document.querySelector("#menu-id"))}
4041
<Router>
41-
<Parcel path="/earn/find/challenges" config={() => System.import('@topcoder/micro-frontends-challenges-app')} />
42-
<Parcel path="/earn/my-gigs" config={() => System.import('@topcoder/micro-frontends-gigs-app')} />
43-
<Redirect from="/earn/*" to="/earn/find/challenges" noThrow />
42+
<Parcel
43+
path="/earn/find/challenges/*"
44+
config={() =>
45+
System.import("@topcoder/micro-frontends-challenges-app")
46+
}
47+
/>
48+
<Parcel
49+
path="/earn/my-gigs"
50+
config={() => System.import("@topcoder/micro-frontends-gigs-app")}
51+
/>
4452
</Router>
4553
</>
4654
);

0 commit comments

Comments
 (0)