import { GoodsTableType } from "@/types";

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

// 定义 action 类型
type GoodsActionType = {
  type: "goods/getList";
  payload: { list: GoodsTableType[]; total: number };
};

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