// 初始化状态
import { MartyrItem } from '@/types/api/martyr'

const initState = {
  // 列表数据
  tableInfo: {
    list: [] as MartyrItem[],
    total: 0
  }
}

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

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

    default:
      return state
  }
}
