import api from "@/axios";

type DictType =
    'CheckStatus'
    | 'DeleteFlag'
    | 'IsEnable'
    | 'IsOrNot'
    | 'Sex'
    | 'ServiceProjectType'
    | 'MiniProgramUserIdentity'
    | 'EnterprisesUnitType'
    | 'SelectType'

export const initDict = () => {
    api.get<Record<DictType, SelectNodeVo<any>[]>>('/common/enums').then(resp => {
        sessionStorage.setItem('dictMap', JSON.stringify(resp.data))
    })
}

export const dictSelectNodes = <T>(dictType: DictType): SelectNodeVo<T>[] => JSON.parse(sessionStorage.getItem('dictMap') as string)?.[dictType] || []

