Work Item and Activity screens mostly complete

This commit is contained in:
John Lyon-Smith
2018-04-03 17:25:59 -07:00
parent 410d2fde4f
commit 72af9a7035
25 changed files with 512 additions and 141 deletions

View File

@@ -17,25 +17,25 @@ export class ProtectedRoute extends React.Component {
componentDidMount() {
api.addListener('login', this.updateComponent)
api.addListener('logout', this.updateComponent)
}
componentWillUnmount() {
api.removeListener('login', this.updateComponent)
api.removeListener('logout', this.updateComponent)
}
render(props) {
const user = api.loggedInUser
if (user) {
if (user.pending) {
// The API might be in the middle of fetching the user information
return null
} else if (!this.props.admin || (this.props.admin && user.administrator)) {
if (user.pending) {
return null
} else {
if (!user._id || (this.props.admin && !user.administrator)) {
return <Redirect to='/login' />
} else {
return <Route {...this.props} />
}
}
// TODO: Can add redirect back in here - see website
return <Redirect to='/login' />
}
}