/** @format */

import { getDictConfig } from "@/api/login";
export async function useDict(...args) {
  let dictList = [];
  for (let key of args) {
    dictList.push(getDictConfig({ key }));
  }
  let syncRes = await Promise.all(dictList);
  return syncRes[0].data;
}

export function paraseDict(dictList, value) {
  if (!dictList.length) return "";

  let arr = dictList.filter((dict) => dict.dictValue == value);

  if (!arr.length) {
    return "";
  }

  return arr[0].dictLabel;
}
