import {getMapValueByKey} from "@/utils/objectUtil";
import {clientType,} from "@/utils/constant";

export const getOwnerName = (musicSheetExtend: any, sourceType: string) => {
  if (sourceType == 'PLATFORM') {
    return "--"
  }
  let ownerName = '';

  if (musicSheetExtend) {
    const appName = musicSheetExtend.applicationName;
    if (sourceType == 'ORG') {
      const organizationRole = musicSheetExtend.organizationRole ? '-' + musicSheetExtend.organizationRole : '';
      ownerName += appName + organizationRole
    } else if (sourceType == 'PERSON') {
      if (musicSheetExtend?.userName) {
        ownerName = musicSheetExtend.userName
      }
      let typeName = getMapValueByKey(musicSheetExtend.clientType, new Map(Object.entries(clientType)));
      typeName = typeName ? '-' + typeName : '';
      ownerName += ' (' + appName + typeName + ')'
    }
  }
  return ownerName;
}