import { HomeSortType, HomeModelType } from "@/types"



// 初始化状态应用注解
const initState = {
  sortList: [] as HomeSortType[],
  ageList: [] as HomeSortType[],
  modelInfo: {} as HomeModelType
}

type HomeActionType =
| { type: 'home/setSort', payload: HomeSortType[] }
| { type: 'home/setAge', payload: HomeSortType[] }
| { type: 'home/setList', payload: HomeModelType }

// 频道 reducer
export default function loginReducer(state = initState, action: HomeActionType) {
  switch (action.type) {
    case 'home/setSort':
      return { ...state, sortList: action.payload }
      case 'home/setAge':
        return { ...state, ageList: action.payload }
      case 'home/setList':
      return { ...state, modelInfo: action.payload }
    default:
      return state
  }
}