Skip to content

Commit 83cb08a

Browse files
committed
availabilities: show error if not allowed / logged out #33
1 parent 477068e commit 83cb08a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

client/components/Availabilities.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import _ from 'lodash';
33
import Timeline from 'react-calendar-timeline';
44
import moment from 'moment';
5-
import { Spinner } from 'elemental';
5+
import { Alert, Spinner } from 'elemental';
66
import * as http from '../lib/http';
77
import groupsJSON from '../../shared/groups.json';
88

@@ -25,12 +25,14 @@ export default React.createClass({
2525
items: [],
2626
groups: [],
2727
volunteers: null,
28+
error: null,
2829
};
2930
},
3031

3132
componentDidMount() {
3233
http.get('/api/volunteers')
33-
.then(({ volunteers }) => this.setState({ volunteers }, this.generateItems));
34+
.then(({ volunteers }) => this.setState({ volunteers }, this.generateItems))
35+
.catch(({ error }) => this.setState({ error }));
3436
},
3537

3638
generateItems() {
@@ -59,6 +61,14 @@ export default React.createClass({
5961
},
6062

6163
render() {
64+
if (this.state.error) {
65+
return (
66+
<div className="container" style={{ marginTop: 100 }}>
67+
<Alert type="danger"><strong>Error:</strong> {this.state.error}</Alert>
68+
</div>
69+
);
70+
}
71+
6272
if (this.state.volunteers === null) {
6373
return <div style={{ marginTop: 100, textAlign: 'center' }}><Spinner size="lg" /></div>;
6474
}

0 commit comments

Comments
 (0)