import { routerRedux } from 'dva/router';
import * as syncService from '../../services/FM/syncData';

export default {

  namespace: 'FMSyncData',
  state: {
  },

  subscriptions: {
    setup({ dispatch, history }) {  // eslint-disable-line
    },
  },
  effects: {
    *SyncWarehouse ({ payload,onComplete }, { call, put }) {
      const ret = yield call(syncService.exeWarehousedate, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *SyncInventory ({ payload,onComplete }, { call, put }) {
      const ret = yield call(syncService.exeInventorydate, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *SyncWorkstage ({ payload,onComplete }, { call, put }) {
      const ret = yield call(syncService.exeWorkstagedate, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *SyncProduct ({ payload,onComplete }, { call, put }) {
      const ret = yield call(syncService.exeProductdate, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *SyncExternalOrder ({ payload,onComplete }, { call, put }) {
      const ret = yield call(syncService.exeOrderdate, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *SyncExternalMaterial ({ payload,onComplete }, { call, put }) {
      const ret = yield call(syncService.exeMaterial, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    }
  },

  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    },
  },

};
