|
| 1 | +import { Panel, PersonaSize, Separator } from '@fluentui/react'; |
| 2 | +import * as React from 'react'; |
| 3 | +import { useDynamicReducer } from '@micro-frontend-react/employee-experience/lib/useDynamicReducer'; |
| 4 | +import { Context, withContext } from '@micro-frontend-react/employee-experience/lib/Context'; |
| 5 | +import { IEmployeeExperienceContext } from '@micro-frontend-react/employee-experience/lib/IEmployeeExperienceContext'; |
| 6 | +import { getIsProfilePanelOpen, getProfile } from './Shared/SharedComponents.selectors'; |
| 7 | +import { ActionButton } from '@fluentui/react/lib/Button'; |
| 8 | +import { toggleProfilePanel } from './Shared/SharedComponents.actions'; |
| 9 | +import { Persona } from './Shared/Components/Persona'; |
| 10 | + |
| 11 | +export function ProfilePanel(): React.ReactElement { |
| 12 | + const { useSelector, dispatch, authClient } = React.useContext( |
| 13 | + Context as React.Context<IEmployeeExperienceContext> |
| 14 | + ); |
| 15 | + const isProfilePanelOpen = useSelector(getIsProfilePanelOpen); |
| 16 | + const profile = useSelector(getProfile); |
| 17 | + |
| 18 | + const handleProfileDismiss = (): void => { |
| 19 | + dispatch(toggleProfilePanel(false)); |
| 20 | + }; |
| 21 | + |
| 22 | + const handleLogout = (): void => { |
| 23 | + authClient.logOut(); |
| 24 | + }; |
| 25 | + |
| 26 | + return ( |
| 27 | + <Panel |
| 28 | + isLightDismiss |
| 29 | + isOpen={isProfilePanelOpen} |
| 30 | + onDismiss={handleProfileDismiss} |
| 31 | + closeButtonAriaLabel="Close profile panel" |
| 32 | + headerText="Profile" |
| 33 | + > |
| 34 | + <Persona |
| 35 | + emailAlias={profile?.userPrincipalName} |
| 36 | + size={PersonaSize.size56} |
| 37 | + text={profile?.displayName} |
| 38 | + secondaryText={profile?.userPrincipalName} |
| 39 | + styles={{ root: { paddingTop: '20px' } }} |
| 40 | + /> |
| 41 | + <Separator /> |
| 42 | + <ActionButton styles={{ label: { color: '#0078d4' }, root: { marginLeft: '-5px' } }} onClick={handleLogout}> |
| 43 | + Sign out |
| 44 | + </ActionButton> |
| 45 | + </Panel> |
| 46 | + ); |
| 47 | +} |
0 commit comments