11import "./Sidebar.scss" ;
22import Accordion from "react-bootstrap/Accordion" ;
3- import React , { useEffect , useState } from "react" ;
3+ import React , { useEffect , useMemo , useState } from "react" ;
44import { useHistory , useLocation } from "react-router-dom" ;
55import { useTranslation } from "react-i18next" ;
66import {
@@ -12,7 +12,8 @@ import {
1212 ENABLE_APPLICATIONS_MODULE ,
1313 ENABLE_TASKS_MODULE ,
1414 ENABLE_INTEGRATION_PREMIUM ,
15- IS_ENTERPRISE
15+ IS_ENTERPRISE ,
16+ USER_NAME_DISPLAY_CLAIM
1617} from "../constants/constants" ;
1718import { StorageService , StyleServices } from "@formsflow/service" ;
1819import i18n from "../resourceBundles/i18n" ;
@@ -122,7 +123,16 @@ const Sidebar = React.memo(({ props, sidenavHeight="100%" }) => {
122123 return initials . substring ( 0 , 2 ) . toUpperCase ( ) ; // Get the first two initials
123124 } ;
124125
125- const userName = userDetail ?. name || userDetail ?. preferred_username || "" ;
126+
127+ // fetch the username form the user details
128+ const userName = useMemo ( ( ) => {
129+ const value = userDetail [ USER_NAME_DISPLAY_CLAIM ] || userDetail ?. name || userDetail ?. preferred_username || "" ;
130+ if ( Array . isArray ( value ) ) {
131+ return value . length > 0 ? value [ 0 ] : "" ;
132+ }
133+ return value ;
134+ } , [ userDetail ] ) ;
135+
126136 const initials = getInitials ( userName ) ;
127137
128138 React . useEffect ( ( ) => {
0 commit comments