content: import React from 'react';
  import {IndexRoute, Route} from 'react-router';
  import {isLoaded as isAuthLoaded, load as loadAuth} from 'redux/modules/auth';
  import {
  	Landing,
  	Apps,
  	App,
  	Signin,
  	Signup,
  	Chat,
  	Home,
  	Widgets,
  	About,
  	LoginSuccess,
  	Survey,
  	NotFound,
  } from './containers';
  
  export default (store) => {
  	const checkLogin = (nextState, replace, cb) => {
  		function checkAuth() {
  			console.log('start checkAuth');
  			const {auth: {user}} = store.getState();
  			if (!user) {
  				console.log('oops, not logged, so cant\'t be here');
  				// oops, not logged in, so can't be here!
  				replace('/');
  			}
  			console.log('next cb..');
  			cb();
  		}
  
  		console.log('start isAuthLoaded');
  		if (!isAuthLoaded(store.getState())) {
  			console.log('start loadAuth');
  			store.dispatch(loadAuth()).then(checkAuth).catch(checkAuth);
  		} else {
  			console.log('start loadAuth 222');
  			checkAuth();
  		}
  	};
  
  	/**
  	 * Please keep routes in alphabetical order
  	 */
  	return (
  		<Route path="/" component={Apps}>
  			{ /* Home (main) route */ }
  			<IndexRoute component={Landing}/>
  			<Route path="signin" component={Signin}/>
  			<Route path="signup" component={Signup}/>
  			<Route path="home" component={Home} onEnter={checkLogin}/>
  
  			{ /* Routes requiring login */ }
  			<Route onEnter={checkLogin}>
  				<Route path="chat" component={Chat}/>
  				<Route path="loginSuccess" component={LoginSuccess}/>
  			</Route>
  
  			{ /* Routes */ }
  			<Route path="about" component={About} onEnter={checkLogin}/>
  			<Route path="survey" component={Survey} onEnter={checkLogin}/>
  			<Route path="widgets" component={Widgets} onEnter={checkLogin}/>
  
  			{ /* Catch all route */ }
  			<Route path="*" component={NotFound} status={404}/>
  		</Route>
  	);
  };
  