import * as reworkPdtOrderService from '../../services/MM/reworkPdtOrderService';

export default {
  namespace: 'reworkPdtOrder',
  state: {
  },
  subscriptions: {
    setup({ dispatch, history }) {  // eslint-disable-line

    },
  },
  effects: {
    *GetReworkSN({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.GetSNOrderEntities, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *GetReworkSNByPdtOrder({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.GetReworkSNByPdtOrder, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *GetReworkProcedure({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.GetReworkProcedure, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *GetReworkJobEntities({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.GetReworkJobEntities, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getJobFeeds({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.getJobFeeds, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getWorkstageByLine({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.getWorkstageByLine, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *CancelRework({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.CancelRework, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *ReworkConfirm({ payload, onComplete }, { call, put }) {
      const ret = yield call(reworkPdtOrderService.Confirm, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    }
  },
  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    },
  }
}