import { B2tableType } from "@/types";

// 初始化状态
const initState = {
  // 列表数据
  tableInfo1: {
    list: [] as B2tableType[],
    total: 0,
  },
  tableInfo2: {
    list: [] as B2tableType[],
    total: 0,
  },
};

// 定义 action 类型
type Props =
  | {
      type: "B2/getList1";
      payload: { list: B2tableType[]; total: number };
    }
  | {
      type: "B2/getList2";
      payload: { list: B2tableType[]; total: number };
    };

// reducer
export default function Reducer(state = initState, action: Props) {
  switch (action.type) {
    // 获取列表数据
    case "B2/getList1":
      return { ...state, tableInfo1: action.payload };
    case "B2/getList2":
      return { ...state, tableInfo2: action.payload };

    default:
      return state;
  }
}
