register.js 631 Bytes
Newer Older
1
import { fakeRegister } from '../services/api';
2 3
import { setAuthority } from '../utils/authority';
import { reloadAuthorized } from '../utils/Authorized';
4 5 6 7 8 9 10 11 12

export default {
  namespace: 'register',

  state: {
    status: undefined,
  },

  effects: {
afc163's avatar
afc163 committed
13
    *submit(_, { call, put }) {
14 15 16 17 18 19 20 21 22 23
      const response = yield call(fakeRegister);
      yield put({
        type: 'registerHandle',
        payload: response,
      });
    },
  },

  reducers: {
    registerHandle(state, { payload }) {
24 25
      setAuthority('user');
      reloadAuthorized();
26 27 28 29 30 31 32
      return {
        ...state,
        status: payload.status,
      };
    },
  },
};