import { A2TableType } from "@/types";

// 初始化状态
const initState = {
  // 外层列表数据
  tableInfo: {
    list: [] as A2TableType[],
    total: 0,
  },
  // 里程数据
  inTableInfo: [] as A2TableType[],
};

// 定义 action 类型
type Props =
  | { type: "A2/getList"; payload: { list: A2TableType[]; total: number } }
  | { type: "A2/inGetList"; payload: A2TableType[] };

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

    default:
      return state;
  }
}
