aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/container
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-07-06 21:01:51 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-07-06 21:01:59 +0200
commit7f1dc831265e0ba4f7f13a0e307daf28d91f8a90 (patch)
treec330848bf738aa90dee9e13ca1c10caa61d60b49 /src/client/react/components/container
parent74ef968a45e147069d044fbfde814886d7275aa3 (diff)
client/schedule: Properly handle errors
Diffstat (limited to 'src/client/react/components/container')
-rw-r--r--src/client/react/components/container/View.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/client/react/components/container/View.js b/src/client/react/components/container/View.js
index a601226..68bdde9 100644
--- a/src/client/react/components/container/View.js
+++ b/src/client/react/components/container/View.js
@@ -26,6 +26,7 @@ import extractSchedule from '../../lib/extractSchedule';
import Schedule from '../presentational/Schedule';
import Loading from '../presentational/Loading';
+import ScheduleErrorDisplay from '../presentational/ScheduleErrorDisplay';
import * as actions from '../../store/actions';
class View extends React.Component {
@@ -45,6 +46,14 @@ class View extends React.Component {
fetchScheduleIfNeeded(user, week);
}
+ componentDidUpdate(prevProps) {
+ const { fetchScheduleIfNeeded, user, week } = this.props;
+
+ if (prevProps.user !== user || prevProps.week !== week) {
+ fetchScheduleIfNeeded(user, week);
+ }
+ }
+
render() {
const {
user,
@@ -60,6 +69,8 @@ class View extends React.Component {
return <Loading />;
case 'FINISHED':
return <Schedule htmlStr={schedule.htmlStr} />;
+ case 'ERROR':
+ return <ScheduleErrorDisplay error={schedule.error} />;
default:
throw new Error(`${schedule.state} is not a valid schedule state.`);
}
@@ -70,7 +81,6 @@ const mapStateToProps = (state) => {
const user = selectUser(state);
const week = selectWeek(state);
return {
- key: `${user}:${week}`,
user,
week,
schedules: state.schedules,