Created
March 20, 2019 09:48
-
-
Save siddhant1/5d1803004addc3fae0c930aa2ab96323 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React from 'react'; | |
import { Route, Router } from 'react-router-dom'; | |
import App from './App'; | |
import Home from './Components/Home'; | |
import Callback from './Components/Callback'; | |
import Auth from './Auth/Auth'; | |
import history from './history'; | |
import GetAllTodos from './Components/GetAllTodos'; | |
const auth = new Auth(); | |
const handleAuthentication = (nextState, replace) => { | |
if (/access_token|id_token|error/.test(nextState.location.hash)) { | |
auth.handleAuthentication(); | |
} | |
} | |
export const makeMainRoutes = () => { | |
return ( | |
<Router history={history} component={App}> | |
<div> | |
<Route path="/" render={(props) => <App auth={auth} {...props} />} /> | |
<Route path="/manage" render={(props) => <Home auth={auth} {...props} />} /> | |
<Route path="/alltodos" render={(props) => <GetAllTodos auth={auth} {...props} />} /> | |
<Route path="/callback" render={(props) => { | |
handleAuthentication(props); | |
return <Callback {...props} /> | |
}} /> | |
</div> | |
</Router> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment