Last active
June 26, 2016 14:02
-
-
Save wolves/8ddf90abb16534c761bc8200bd5d8d1b to your computer and use it in GitHub Desktop.
react-router routes file
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
import React from 'react' | |
import { Route, IndexRoute } from 'react-router' | |
import App from './containers/App' | |
import Login from './containers/Login' | |
import Dashboard from './containers/Dashboard' | |
import SearchContainer from './containers/Search' | |
import Cart from './containers/Cart' | |
import Maintenance from './containers/Maintenance' | |
import Profile from './containers/Profile' | |
import Help from './containers/Help' | |
import LoginForm from './components/Accounts/LoginForm' | |
import RegisterForm from './components/Accounts/RegisterForm' | |
import PasswordRecovery from './components/Accounts/PasswordRecovery' | |
import ChangeOrder from './components/Purchasing/ChangeOrder' | |
import Quotes from './components/Purchasing/Quotes' | |
import Return from './components/Purchasing/Return' | |
import OpenItems from './components/Invoicing/OpenItems' | |
import Payments from './components/Search/Payments' | |
import Pay from './components/Invoicing/Pay' | |
import Monitoring from './components/Admin/Monitoring' | |
import Proxy from './components/Admin/Proxy' | |
function requireAuth(nextState, replace) { | |
// Figure out how to access redux state from within routes file | |
// const { auth } = this.state | |
if (!auth.isAuthenticated) { | |
replace({ | |
pathname: '/login', | |
state: { nextPathname: nextState.location.pathname } | |
}) | |
} | |
} | |
export default ( | |
<Route path='/' component={App}> | |
<IndexRoute component={Dashboard} onEnter={requireAuth} /> | |
<Route path='login' component={LoginForm}/> | |
<Route path='register' component={RegisterForm}/> | |
<Route path='recover-password' component={PasswordRecovery}/> | |
<Route onEnter={requireAuth}> | |
<Route path='dashboard' component={Dashboard} /> | |
<Route path='search/:type' component={SearchContainer}/> | |
<Route path='cart' component={Cart}/> | |
<Route path='change-order' component={ChangeOrder}/> | |
<Route path='quotes' component={Quotes}/> | |
<Route path='return' component={Return}/> | |
<Route path='open-items' component={OpenItems}/> | |
<Route path='pay' component={Pay}/> | |
<Route path='payments' component={Payments}/> | |
<Route path='maintenance/:type' component={Maintenance}/> | |
<Route path='monitoring' component={Monitoring}/> | |
<Route path='proxy' component={Proxy}/> | |
<Route path='profile' component={Profile}/> | |
<Route path='help' component={Help}/> | |
</Route> | |
</Route> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment