-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
7,469 additions
and
5,413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"tabWidth": 2, | ||
"singleQuote": false, | ||
"semi": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,76 @@ | ||
import React from 'react'; | ||
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom'; | ||
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles'; | ||
import React from "react"; | ||
import { BrowserRouter, Route, Switch, Redirect } from "react-router-dom"; | ||
|
||
import themes, { overrides } from '../themes'; | ||
import Layout from './Layout'; | ||
import Error from '../pages/error'; | ||
import Login from '../pages/login'; | ||
// components | ||
import Layout from "./Layout"; | ||
|
||
const theme = createMuiTheme({ | ||
...themes.default, | ||
...overrides, | ||
typography: { | ||
useNextVariants: true, | ||
},}); | ||
// pages | ||
import Error from "../pages/error"; | ||
import Login from "../pages/login"; | ||
|
||
const PrivateRoute = ({ component, ...rest }) => { | ||
return ( | ||
<Route | ||
{...rest} render={props => ( | ||
localStorage.getItem('id_token') ? ( | ||
React.createElement(component, props) | ||
) : ( | ||
<Redirect | ||
to={{ | ||
pathname: '/login', | ||
state: { from: props.location }, | ||
}} | ||
/> | ||
) | ||
)} | ||
/> | ||
); | ||
}; | ||
// context | ||
import { useUserState } from "../context/UserContext"; | ||
|
||
const PublicRoute = ({ component, ...rest }) => { | ||
return ( | ||
<Route | ||
{...rest} render={props => ( | ||
localStorage.getItem('id_token') ? ( | ||
<Redirect | ||
to={{ | ||
pathname: '/', | ||
}} | ||
/> | ||
) : ( | ||
React.createElement(component, props) | ||
) | ||
)} | ||
/> | ||
); | ||
}; | ||
export default function App() { | ||
// global | ||
var { isAuthenticated } = useUserState(); | ||
|
||
const App = () => ( | ||
<MuiThemeProvider theme={theme}> | ||
return ( | ||
<BrowserRouter> | ||
<Switch> | ||
<Route exact path="/" render={() => <Redirect to="/app/dashboard" />} /> | ||
<Route exact path="/app" render={() => <Redirect to="/app/dashboard" />} /> | ||
<Route | ||
exact | ||
path="/app" | ||
render={() => <Redirect to="/app/dashboard" />} | ||
/> | ||
<PrivateRoute path="/app" component={Layout} /> | ||
<PublicRoute path="/login" component={Login} /> | ||
<Route component={Error} /> | ||
</Switch> | ||
</BrowserRouter> | ||
</MuiThemeProvider> | ||
); | ||
); | ||
|
||
// ####################################################################### | ||
|
||
function PrivateRoute({ component, ...rest }) { | ||
return ( | ||
<Route | ||
{...rest} | ||
render={props => | ||
isAuthenticated ? ( | ||
React.createElement(component, props) | ||
) : ( | ||
<Redirect | ||
to={{ | ||
pathname: "/login", | ||
state: { | ||
from: props.location, | ||
}, | ||
}} | ||
/> | ||
) | ||
} | ||
/> | ||
); | ||
} | ||
|
||
export default App; | ||
function PublicRoute({ component, ...rest }) { | ||
return ( | ||
<Route | ||
{...rest} | ||
render={props => | ||
isAuthenticated ? ( | ||
<Redirect | ||
to={{ | ||
pathname: "/", | ||
}} | ||
/> | ||
) : ( | ||
React.createElement(component, props) | ||
) | ||
} | ||
/> | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.