Skip to content

Commit df01e8f

Browse files
committed
squash! feat: account linking page
1 parent 7ffe2cc commit df01e8f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/ui/utils/user.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ export function getUserInitials(userRef: any) {
2626
if (!user) {
2727
return
2828
}
29-
const name =
30-
user.name || [user.profile.first_name, user.profile.middle_name, user.profile.last_name].filter((v) => !!v).join(' ')
29+
const profile = user.profile || {}
30+
const name = user.name || [
31+
profile.first_name,
32+
profile.middle_name,
33+
profile.last_name
34+
].filter((v) => !!v).join(' ')
35+
3136
if (name) {
3237
return name
3338
.match(/(^\w\w?|\s\w)?/g)
@@ -37,12 +42,8 @@ export function getUserInitials(userRef: any) {
3742
.join('')
3843
.toLocaleUpperCase()
3944
}
40-
if (user.email) {
41-
return user.email.charAt(0).toUpperCase() + user.email.charAt(1).toUpperCase()
42-
}
43-
if (user.username) {
44-
return user.username.charAt(0).toUpperCase() + user.username.charAt(1).toUpperCase()
45-
}
45+
const identifier = user.email || user.username || user.phone_number || user.id
46+
return identifier.charAt(0).toUpperCase() + (identifier.charAt(1)?.toUpperCase() || '')
4647
}
4748

4849
function getHslVars(initials: string) {

0 commit comments

Comments
 (0)