import { A1TableType } from "@/types";

// 初始化状态
const initState = {
  // 列表数据
  tableInfo: {
    list: [
      { id: 1, a: 1, b: 2, c: 3, d: 4, e: 5 },
      { id: 2, a: 1, b: 2, c: 3, d: 4, e: 5 },
    ] as A1TableType[],
    total: 2,
  },
};

// 定义 action 类型
type Props = {
  type: "A1/getList";
  payload: { list: A1TableType[]; total: number };
};

// 频道 reducer
export default function A1Reducer(state = initState, action: Props) {
  switch (action.type) {
    // 获取列表数据
    case "A1/getList":
      return { ...state, tableInfo: action.payload };

    default:
      return state;
  }
}
