Skip to content

Commit

Permalink
availabilities: show error if not allowed / logged out #33
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbeier committed May 11, 2017
1 parent 477068e commit 83cb08a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions client/components/Availabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import _ from 'lodash';
import Timeline from 'react-calendar-timeline';
import moment from 'moment';
import { Spinner } from 'elemental';
import { Alert, Spinner } from 'elemental';
import * as http from '../lib/http';
import groupsJSON from '../../shared/groups.json';

Expand All @@ -25,12 +25,14 @@ export default React.createClass({
items: [],
groups: [],
volunteers: null,
error: null,
};
},

componentDidMount() {
http.get('/api/volunteers')
.then(({ volunteers }) => this.setState({ volunteers }, this.generateItems));
.then(({ volunteers }) => this.setState({ volunteers }, this.generateItems))
.catch(({ error }) => this.setState({ error }));
},

generateItems() {
Expand Down Expand Up @@ -59,6 +61,14 @@ export default React.createClass({
},

render() {
if (this.state.error) {
return (
<div className="container" style={{ marginTop: 100 }}>
<Alert type="danger"><strong>Error:</strong> {this.state.error}</Alert>
</div>
);
}

if (this.state.volunteers === null) {
return <div style={{ marginTop: 100, textAlign: 'center' }}><Spinner size="lg" /></div>;
}
Expand Down

0 comments on commit 83cb08a

Please sign in to comment.