This commit is contained in:
41666 2018-01-15 15:46:18 -06:00
parent 86a222fb98
commit 032831aff1
5 changed files with 138 additions and 17 deletions

View file

@ -7,7 +7,7 @@ import Servers from '../components/servers'
import OauthCallback from '../components/oauth-callback'
import OauthFlow from '../components/oauth-flow'
import OauthBotFlow from '../components/oauth-bot-flow'
import Pages, { Landing } from '../pages'
import Pages, { Landing, Error404, ServerLanding } from '../pages'
const aaa = (props) => (<div>{ JSON.stringify(props) }</div>)
@ -15,15 +15,28 @@ const aaa = (props) => (<div>{ JSON.stringify(props) }</div>)
@connect(({ appState, user }) => ({ ready: appState.ready, user }))
export default class AppRouter extends Component {
render () {
const isLoggedIn = this.props.user.get('isLoggedIn')
if (!this.props.ready) {
return null
}
return <Switch>
<Route path='/s' component={Servers} />
{ (isLoggedIn)
<Route path='/root' component={aaa} />
// YES LOGGED IN
? <Fragment>
<Route path='/s' component={Servers} />
<Route path='/root' component={aaa} />
</Fragment>
// NOT LOGGED IN
: <Fragment>
<Route path='/s' component={ServerLanding} />
</Fragment>
}
{/* GENERAL ROUTES */}
<Route path='/oauth/callback' component={OauthCallback} />
<Route path='/oauth/flow' component={OauthFlow} />
<Route path='/oauth/bot/flow' component={OauthBotFlow} />
@ -32,10 +45,12 @@ export default class AppRouter extends Component {
<Route path='/help' component={Pages} />
<Route exact path='/' render={() =>
this.props.user.get('isLoggedIn')
isLoggedIn
? <Redirect to="/s" />
: <Landing root={true} />
} />
<Route component={Error404} />
</Switch>
}
}