File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
4849function getHslVars ( initials : string ) {
You can’t perform that action at this time.
0 commit comments