import { cloneDeep } from 'lodash-es';
import { useDict } from './useDict';
import { getTagKeyMap } from './enum/node';

export const disposeSimType = (demandType: string, simType:string) => {
  if (demandType && simType) {
    const dict:any = useDict(demandType);
    if (dict[demandType].value.O[simType]) {
      return dict[demandType].value.O[simType];
    }
  }
  return simType;
};

/**
 *
 * @param memberList
 * @returns 用户ids，逗号隔开的id字符串
 */
export const getMemberListIds = (memberList: any[]) => {
  const list = cloneDeep(memberList);
  if (Array.isArray(list)) {
    return list.map((item:any) => {
      return item.userId;
    }).join(',');
  }
  return '';
};

export const getTagMapList = () => {
  const tagMap = getTagKeyMap();
  const tagMapList: { key: string; value: string; }[] = [];
  tagMap.forEach((value: string, key: string) => {
    tagMapList.push({
      key: key,
      value: value,
    });
  });
  return tagMapList;
};

