Skip to content

Instantly share code, notes, and snippets.

@siddhant1
Created March 20, 2019 09:48
Show Gist options
  • Save siddhant1/5d1803004addc3fae0c930aa2ab96323 to your computer and use it in GitHub Desktop.
Save siddhant1/5d1803004addc3fae0c930aa2ab96323 to your computer and use it in GitHub Desktop.
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