register.js 647 Bytes
Newer Older
sorrycc's avatar
sorrycc committed
1 2 3
import { fakeRegister } from '@/services/api';
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: {
Advoster's avatar
Advoster committed
13 14
    *submit({ payload }, { call, put }) {
      const response = yield call(fakeRegister, payload);
15 16 17 18 19 20 21 22 23
      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,
      };
    },
  },
};