Merge branch 'IDTEAM-1.26.0' into 'main'
[ProtonMail-WebClient.git] / packages / shared / lib / helpers / getUsername.ts
blob2036841a221ba5c190c5e6c033f3c5ff20451bec
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;