import { Map, fromJS, List } from 'immutable'
const initCustomSearchObj = {
  pageIndex: 1,
  pageSize: 10
}
export function customSearchForm(state = Map(initCustomSearchObj), action) {
  let { pageIndex, pageSize } = state.toJS()
  switch (action.type) {
    case 'init':
      state = fromJS({...initCustomSearchObj})
      return state
    case 'reset':
      state = fromJS({...initCustomSearchObj, pageIndex, pageSize})
      return state
    case 'update':
      return state.sfs(fromJS(action.data))
    default:
      return state
  }
}

export function customTableData(state = List(), action) {
  switch (action.type) {
    case 'update':
      state = List(fromJS(action.data))
      return state
    default:
      return state
  }
}

export function customPagination(state = Map({
  pageIndex: 1,
  pageSize: 10,
  recordCount: 0,
}), action) {
  switch (action.type) {
    case 'update':
      state = fromJS(action.data)
      return state
    default:
      return state
  }
}