import { Z0tableType } from "@/types";

// 初始化状态
const initState = {
  // 列表数据
  tableInfo: {
    dynamic: [] as Z0tableType[],
    goods: [] as Z0tableType[],
    activity: [] as Z0tableType[],
  },
};

// 定义 action 类型
type Props = {
  type: "Z0/getList";
  payload: {
    dynamic: Z0tableType[];
    goods: Z0tableType[];
    activity: Z0tableType[];
  };
};

// reducer
export default function userReducer(state = initState, action: Props) {
  switch (action.type) {
    // 获取列表数据
    case "Z0/getList":
      return { ...state, tableInfo: action.payload };

    default:
      return state;
  }
}
