myUser.js 1.23 KB
import { notifyError } from '../services/app.js';
import { getAllUser,deleteCustomer,GetRoomList } from '../services/myUser';





export default {
  namespace: 'myUser',
  state: {
    item: {},

  },
  effects: {

    *getAllUser({ payload, callback }, { call, put }) {
      const { data } = yield call(getAllUser, payload);
      if (data.status === true) {
        if(data.data.length===1){
         yield put({
           type: 'saveUser',
           payload: data.data,
         });
       }
        if (callback) callback(data.data);
      } else {
        notifyError(data.message);
      }
    },
    *deleteCustomer({ payload, callback }, { call, put }) {
      const { data } = yield call(deleteCustomer, payload);
      if (data.status === true) {
        if (callback) callback(data.data);
      } else {
        notifyError(data.message);
      }
    },
    *getRoomList({ payload, callback }, { call, put }) {
      const { data } = yield call(GetRoomList, payload);
      if (data.code === 0) {
        if (callback) callback(data);
      } else {
        notifyError(data.message);
      }
    },





  },
  reducers: {
    saveUser(state, { payload }) {
      return { ...state, item: payload };
    },

  },
  subscriptions: {

  },
};