Become a Pro / website · becomeapro.ai / src / lib / display-name.ts
| 1 | type DisplayUser = { name?: string | null }; |
| 2 | |
| 3 | export const FALLBACK_NAME = "Builder"; |
| 4 | |
| 5 | export function displayName(user: DisplayUser): string { |
| 6 | const name = user.name?.trim(); |
| 7 | return name && !name.includes("@") ? name : FALLBACK_NAME; |
| 8 | } |
| 9 | |
| 10 | export function firstName(user: DisplayUser): string { |
| 11 | return displayName(user).split(/\s+/)[0]; |
| 12 | } |