@@ -14,7 +14,7 @@ import {
1414 ENABLE_INTEGRATION_PREMIUM ,
1515 IS_ENTERPRISE
1616} from "../constants/constants" ;
17- import { StorageService } from "@formsflow/service" ;
17+ import { StorageService , StyleServices } from "@formsflow/service" ;
1818import i18n from "../resourceBundles/i18n" ;
1919import { fetchTenantDetails } from "../services/tenant" ;
2020import { setShowApplications } from "../constants/userContants" ;
@@ -26,6 +26,48 @@ import { ApplicationLogo } from "@formsflow/components";
2626import { ProfileSettingsModal } from "./ProfileSettingsModal" ;
2727import PropTypes from 'prop-types' ;
2828
29+ const UserProfile = ( { userDetail, initials, handleProfileModal, logout, t } ) => (
30+ < div className = "user-container" >
31+ < button className = "button-as-div justify-content-start m-2" onClick = { handleProfileModal } >
32+ < div className = "user-icon cursor-pointer" data-testid = "user-icon" >
33+ { initials }
34+ </ div >
35+ < div >
36+ < p className = "user-name" data-testid = "user-name" > { userDetail ?. name } </ p >
37+ < p className = "user-email" data-testid = "user-email" >
38+ { userDetail ?. email || userDetail ?. preferred_username }
39+ </ p >
40+ </ div >
41+ </ button >
42+ < button className = "button-as-div sign-out-button" onClick = { logout } data-testid = "sign-out-button" >
43+ < p className = "m-0" > { t ( "Sign Out" ) } </ p >
44+ </ button >
45+ </ div >
46+ ) ;
47+
48+ UserProfile . propTypes = {
49+ userDetail : PropTypes . shape ( {
50+ name : PropTypes . string ,
51+ email : PropTypes . string ,
52+ preferred_username : PropTypes . string ,
53+ } ) . isRequired ,
54+
55+ initials : PropTypes . string . isRequired ,
56+ handleProfileModal : PropTypes . func . isRequired ,
57+ logout : PropTypes . func . isRequired ,
58+ t : PropTypes . func . isRequired ,
59+ } ;
60+
61+ const renderLogo = ( hideLogo ) => {
62+ if ( hideLogo === "true" ) return null ;
63+
64+ return (
65+ < div className = "logo-container" >
66+ < ApplicationLogo data-testid = "application-logo" />
67+ </ div >
68+ ) ;
69+ } ;
70+
2971const Sidebar = React . memo ( ( { props, sidenavHeight= "100%" } ) => {
3072 const [ tenantLogo , setTenantLogo ] = React . useState ( "" ) ;
3173 const [ tenantName , setTenantName ] = React . useState ( "" ) ;
@@ -39,7 +81,7 @@ const Sidebar = React.memo(({ props, sidenavHeight="100%" }) => {
3981 const tenantKey = tenant ?. tenantId ;
4082 const formTenant = form ?. tenantKey ;
4183 const [ showProfile , setShowProfile ] = useState ( false ) ;
42-
84+ const hideLogo = StyleServices ?. getCSSVariable ( "--hide-formsflow-logo" ) ;
4385 const { t } = useTranslation ( ) ;
4486 const currentLocation = useLocation ( ) ;
4587
@@ -237,15 +279,7 @@ const Sidebar = React.memo(({ props, sidenavHeight="100%" }) => {
237279
238280 return (
239281 < div className = "sidenav" style = { { height : sidenavHeight } } >
240- < div className = "logo-container" >
241- { /* <img
242- className=""
243- src={Appname}
244- alt="applicationName"
245- data-testid="app-logo"
246- /> */ }
247- < ApplicationLogo data-testid = "application-logo" />
248- </ div >
282+ { renderLogo ( hideLogo ) }
249283 < div className = "options-container" data-testid = "options-container" >
250284 < Accordion activeKey = { activeKey } onSelect = { ( key ) => setActiveKey ( key ) } >
251285 { ENABLE_FORMS_MODULE &&
@@ -365,30 +399,14 @@ const Sidebar = React.memo(({ props, sidenavHeight="100%" }) => {
365399 ) }
366400 </ Accordion >
367401 </ div >
368- { isAuthenticated && ( < div className = "user-container" >
369- < button className = "button-as-div justify-content-start m-2" onClick = { handleProfileModal } >
370- < div className = "user-icon cursor-pointer" data-testid = "user-icon" >
371- { initials }
372- </ div >
373- < div >
374- < p
375- className = "user-name"
376- data-testid = "user-name" >
377- { userDetail ?. name }
378- </ p >
379- < p className = "user-email" data-testid = "user-email" >
380- { userDetail ?. email || userDetail ?. preferred_username }
381- </ p >
382- </ div >
383- </ button >
384- < div
385- className = "sign-out-button"
386- onClick = { logout }
387- data-testid = "sign-out-button"
388- >
389- < p className = "m-0" > { t ( "Sign Out" ) } </ p >
390- </ div >
391- </ div > ) }
402+ { isAuthenticated && (
403+ < UserProfile
404+ userDetail = { userDetail }
405+ initials = { initials }
406+ handleProfileModal = { handleProfileModal }
407+ logout = { logout }
408+ t = { t }
409+ /> ) }
392410 {
393411 showProfile && < ProfileSettingsModal
394412 show = { showProfile }
0 commit comments