import { SmartTableType } from "@/types";

// 初始化状态
const initState = {
  // 列表数据
  autoList: [] as SmartTableType[],
  hotList: [] as SmartTableType[],
};

// 定义 action 类型
type SmartActionType =
  | { type: "smart/getAutoList"; payload: SmartTableType[] }
  | { type: "smart/getHotList"; payload: SmartTableType[] };

// 频道 reducer
export default function smartReducer(
  state = initState,
  action: SmartActionType
) {
  switch (action.type) {
    // 获取列表数据
    case "smart/getAutoList":
      return { ...state, autoList: action.payload };
      case "smart/getHotList":
        return { ...state, hotList: action.payload };
      default:
      return state;
  }
}
