import { ReduxAction, ReduxSagaEffects } from '@interfaces';
export default {

  namespace: 'tenderDetailsSupp',

  state: {
    formData: {}
  },

  effects: {
    * addRow({ payload }: ReduxAction, { put, call, select }: ReduxSagaEffects) {
      const { list } = yield select(({ tenderDetails }) => tenderDetails);
      const newList = list.slice();
      newList.push(payload);
      yield put({
        type: 'tenderDetails/updateState',
        payload: {
          list: newList,
        },
      });
    },

    * deleteRow({ payload }: ReduxAction, { put, call, select }: ReduxSagaEffects) {
      const { list } = yield select(({ tenderDetails }) => tenderDetails);
      const newList = list.slice().filter((item) => item.id !== payload);
      yield put({
        type: 'tenderDetails/updateState',
        payload: {
          list: newList,
        },
      });
    },
  },

  reducers: {},
};
