Spaces:
Sleeping
Sleeping
Download frontend/src/lib/userDisplayName.ts from BrainForge/AdvisoryBuilderWorkshop: direct link, hf CLI and curl.
- Browser
- Download file 556 Bytes
-
https://huggingface.co/spaces/BrainForge/AdvisoryBuilderWorkshop/resolve/main/frontend/src/lib/userDisplayName.ts
- Command line
-
hf download hf://spaces/BrainForge/AdvisoryBuilderWorkshop/frontend/src/lib/userDisplayName.ts
-
curl -L -o userDisplayName.ts https://huggingface.co/spaces/BrainForge/AdvisoryBuilderWorkshop/resolve/main/frontend/src/lib/userDisplayName.ts
556 Bytes
| import type { User } from '../context/AuthContext' | |
| /** Best display string for autofill: "First Last", else email local part before @. */ | |
| export function defaultDisplayNameFromUser(user: User | null): string { | |
| if (!user) return '' | |
| const full = [user.firstName, user.lastName] | |
| .map((s) => (typeof s === 'string' ? s.trim() : '')) | |
| .filter(Boolean) | |
| .join(' ') | |
| .trim() | |
| if (full) return full | |
| const email = user.email?.trim() ?? '' | |
| const at = email.indexOf('@') | |
| if (at > 0) return email.slice(0, at) | |
| return email | |
| } | |