import { TopicTableType } from "@/types";

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

// 定义 action 类型
type TopicActionType = {
  type: "topic/getList";
  payload: { list: TopicTableType[]; total: number };
};

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

    default:
      return state;
  }
}
