import { TypeZ1dict } from '@/pages/Z_system/Z1dict/type'

// 初始化状态
const initState = {
  // 所有字典数据
  dictAll: [] as TypeZ1dict[],
  // 列表展示的数据
  dictList: [] as TypeZ1dict[]
}

// 定义 action 类型
type Props =
  | {
      type: 'Z1/getDictAll'
      payload: TypeZ1dict[]
    }
  | {
      type: 'Z1/getList'
      payload: TypeZ1dict[]
    }

// reducer
export default function userReducer(state = initState, action: Props) {
  switch (action.type) {
    // 获取字典数据
    case 'Z1/getDictAll':
      return { ...state, dictAll: action.payload }
    // 获取展示的数据
    case 'Z1/getList':
      return { ...state, dictList: action.payload }
    default:
      return state
  }
}
