Skip to content

Commit 896b6f2

Browse files
committed
updated to latest version (react 16.8.6, react-router-dom 5.0.1, material-ui 4.3.0) use hooks and context instead of redux, remove line-awesome icons, all code refactor to work with hooks
1 parent 3f0a750 commit 896b6f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+7475
-6657
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"tabWidth": 2,
3+
"singleQuote": false,
4+
"semi": true,
5+
"trailingComma": "all"
6+
}

package.json

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
{
22
"name": "flatlogic-material",
33
"version": "1.0.0",
4+
"private": true,
45
"dependencies": {
5-
"@material-ui/core": "^3.9.2",
6-
"@material-ui/icons": "^3.0.2",
7-
"apexcharts": "^3.6.3",
6+
"@material-ui/core": "^4.3.0",
7+
"@material-ui/icons": "^4.2.1",
8+
"@material-ui/styles": "^4.3.0",
9+
"apexcharts": "^3.8.3",
810
"classnames": "^2.2.6",
9-
"font-awesome": "4.7.0",
10-
"line-awesome": "icons8/line-awesome",
11-
"mui-datatables": "^2.0.0-beta.58",
12-
"react": "^16.8.2",
13-
"react-apexcharts": "^1.3.0",
14-
"react-dom": "^16.8.2",
11+
"font-awesome": "^4.7.0",
12+
"mui-datatables": "^2.6.4",
13+
"react": "^16.8.6",
14+
"react-apexcharts": "^1.3.3",
15+
"react-dom": "^16.8.6",
1516
"react-google-maps": "^9.4.5",
16-
"react-redux": "^6.0.1",
17-
"react-router": "^4.3.1",
18-
"react-router-dom": "^4.3.1",
19-
"react-scripts": "2.1.5",
20-
"react-syntax-highlighter": "^10.2.0",
21-
"react-toastify": "^4.5.2",
22-
"recharts": "^1.5.0",
23-
"recompose": "^0.30.0",
24-
"redux": "^4.0.1",
25-
"redux-thunk": "^2.3.0",
17+
"react-router-dom": "^5.0.1",
18+
"react-scripts": "3.0.1",
19+
"react-syntax-highlighter": "^11.0.2",
20+
"react-toastify": "^5.3.2",
21+
"recharts": "^1.6.2",
2622
"tinycolor2": "^1.4.1"
2723
},
2824
"scripts": {
@@ -34,10 +30,16 @@
3430
"eslintConfig": {
3531
"extends": "react-app"
3632
},
37-
"browserslist": [
38-
">0.2%",
39-
"not dead",
40-
"not ie <= 11",
41-
"not op_mini all"
42-
]
33+
"browserslist": {
34+
"production": [
35+
">0.2%",
36+
"not dead",
37+
"not op_mini all"
38+
],
39+
"development": [
40+
"last 1 chrome version",
41+
"last 1 firefox version",
42+
"last 1 safari version"
43+
]
44+
}
4345
}

src/components/App.js

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,76 @@
1-
import React from 'react';
2-
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';
3-
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
1+
import React from "react";
2+
import { BrowserRouter, Route, Switch, Redirect } from "react-router-dom";
43

5-
import themes, { overrides } from '../themes';
6-
import Layout from './Layout';
7-
import Error from '../pages/error';
8-
import Login from '../pages/login';
4+
// components
5+
import Layout from "./Layout";
96

10-
const theme = createMuiTheme({...themes.default, ...overrides});
7+
// pages
8+
import Error from "../pages/error";
9+
import Login from "../pages/login";
1110

12-
const PrivateRoute = ({ component, ...rest }) => {
13-
return (
14-
<Route
15-
{...rest} render={props => (
16-
localStorage.getItem('id_token') ? (
17-
React.createElement(component, props)
18-
) : (
19-
<Redirect
20-
to={{
21-
pathname: '/login',
22-
state: { from: props.location },
23-
}}
24-
/>
25-
)
26-
)}
27-
/>
28-
);
29-
};
11+
// context
12+
import { useUserState } from "../context/UserContext";
3013

31-
const PublicRoute = ({ component, ...rest }) => {
32-
return (
33-
<Route
34-
{...rest} render={props => (
35-
localStorage.getItem('id_token') ? (
36-
<Redirect
37-
to={{
38-
pathname: '/',
39-
}}
40-
/>
41-
) : (
42-
React.createElement(component, props)
43-
)
44-
)}
45-
/>
46-
);
47-
};
14+
export default function App() {
15+
// global
16+
var { isAuthenticated } = useUserState();
4817

49-
const App = () => (
50-
<MuiThemeProvider theme={theme}>
18+
return (
5119
<BrowserRouter>
5220
<Switch>
5321
<Route exact path="/" render={() => <Redirect to="/app/dashboard" />} />
54-
<Route exact path="/app" render={() => <Redirect to="/app/dashboard" />} />
22+
<Route
23+
exact
24+
path="/app"
25+
render={() => <Redirect to="/app/dashboard" />}
26+
/>
5527
<PrivateRoute path="/app" component={Layout} />
5628
<PublicRoute path="/login" component={Login} />
5729
<Route component={Error} />
5830
</Switch>
5931
</BrowserRouter>
60-
</MuiThemeProvider>
61-
);
32+
);
33+
34+
// #######################################################################
35+
36+
function PrivateRoute({ component, ...rest }) {
37+
return (
38+
<Route
39+
{...rest}
40+
render={props =>
41+
isAuthenticated ? (
42+
React.createElement(component, props)
43+
) : (
44+
<Redirect
45+
to={{
46+
pathname: "/login",
47+
state: {
48+
from: props.location,
49+
},
50+
}}
51+
/>
52+
)
53+
}
54+
/>
55+
);
56+
}
6257

63-
export default App;
58+
function PublicRoute({ component, ...rest }) {
59+
return (
60+
<Route
61+
{...rest}
62+
render={props =>
63+
isAuthenticated ? (
64+
<Redirect
65+
to={{
66+
pathname: "/",
67+
}}
68+
/>
69+
) : (
70+
React.createElement(component, props)
71+
)
72+
}
73+
/>
74+
);
75+
}
76+
}

src/components/AppContainer.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)