import { C1ListType } from "@/types";

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

// 定义 action 类型
type Props =
  | { type: "C1/getList"; payload: { list: C1ListType[]; total: number } }
  | { type: "C1/getListAll"; payload: C1ListType[] };

// reducer
export default function Reducer(state = initState, action: Props) {
  switch (action.type) {
    // 获取列表数据
    case "C1/getList":
      return { ...state, C1TableList: action.payload };
    case "C1/getListAll":
      return { ...state, C1TableListAll: action.payload };
    default:
      return state;
  }
}
