1 import type { Address, User } from '../interfaces';
2 import { UserType } from '../interfaces';
3 import { getIsAddressEnabled } from './address';
5 export default function getUsername(user: User, addresses: Address[]) {
6 const primaryAddress = addresses?.find(getIsAddressEnabled);
7 return user.Type === UserType.EXTERNAL && primaryAddress ? primaryAddress.Email : user.Name;