aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/actions/view.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/react/actions/view.js')
-rw-r--r--src/client/react/actions/view.js31
1 files changed, 31 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..79ec143
--- /dev/null
+++ b/src/client/react/actions/view.js
@@ -0,0 +1,31 @@
+// eslint-disable-next-line import/prefer-default-export
+export const fetchSchedule = (user, week) => (dispatch) => {
+ dispatch({
+ type: 'VIEW/FETCH_SCHEDULE_REQUEST',
+ user,
+ week,
+ });
+
+ fetch(`/get/${user}?week=${week}`).then(
+ // success
+ (r) => {
+ r.text().then((htmlStr) => {
+ dispatch({
+ type: 'VIEW/FETCH_SCHEDULE_SUCCESS',
+ user,
+ week,
+ htmlStr,
+ });
+ });
+ },
+
+ // error
+ () => {
+ dispatch({
+ type: 'VIEW/FETCH_SCHEDULE_FAILURE',
+ week,
+ user,
+ });
+ },
+ );
+};