import {
  queryFinanceResReport,
  queryFinanceProjReport,
  queryFinanceProjDetail,
} from '@/services/workHours';
import { message } from 'antd';

export default {
  namespace: 'finance',
  state: {
    resource: [],
    project: {
      list: [],
      pagination: {},
    },
  },

  effects: {
    *queryFinanceResReport({ payload = {} }, { call, put }) {
      const res = yield call(queryFinanceResReport, payload);
      if (res) {
        yield put({
          type: 'save',
          payload: { resource: res.data },
        });
      }
    },
    *queryFinanceProjReport({ payload = {} }, { call, put }) {
      const res = yield call(queryFinanceProjReport, payload);
      if (res) {
        yield put({
          type: 'save',
          payload: { project: res.data },
        });
      }
    },
  },

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