import { A2BListType } from '@/types'

// 初始化状态
const initState = {
  // 列表数据
  A2BTableList: {
    list: [] as A2BListType[],
    total: 0
  }
}

// 定义 action 类型
type Props = {
  type: 'A2B/getList'
  payload: { list: A2BListType[]; total: number }
}

// reducer
export default function Reducer(state = initState, action: Props) {
  switch (action.type) {
    // 获取列表数据
    case 'A2B/getList':
      return { ...state, A2BTableList: action.payload }
    default:
      return state
  }
}
