aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/actions/view.js
blob: f9f0be22201b64e467df6979da5b62cb76a32297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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,
      });
    },
  );
};