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

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

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