diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-01-17 16:26:04 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-01-17 16:26:04 +0100 |
commit | 1b3f4ea79f947558573fbce5a2e2d0c2c5dd6a8d (patch) | |
tree | 52a41cbd31a69de31edf83578e3055d076fa1c3e /src/client/react/actions | |
parent | c0aa588bc8f85b13b5a55ccd6cdf11bf99048a1c (diff) |
Add view code
Diffstat (limited to 'src/client/react/actions')
-rw-r--r-- | src/client/react/actions/view.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/client/react/actions/view.js b/src/client/react/actions/view.js new file mode 100644 index 0000000..f9f0be2 --- /dev/null +++ b/src/client/react/actions/view.js @@ -0,0 +1,28 @@ +// eslint-disable-next-line import/prefer-default-export +export const fetchSchedule = user => (dispatch) => { + dispatch({ + type: 'VIEW/FETCH_SCHEDULE_REQUEST', + user, + }); + + fetch(`/get/${user}`).then( + // success + (r) => { + r.text().then((htmlStr) => { + dispatch({ + type: 'VIEW/FETCH_SCHEDULE_SUCCESS', + user, + htmlStr, + }); + }); + }, + + // error + () => { + dispatch({ + type: 'VIEW/FETCH_SCHEDULE_FAILURE', + user, + }); + }, + ); +}; |