Skip to content

Commit

Permalink
user menu
Browse files Browse the repository at this point in the history
  • Loading branch information
elvincheng3 committed Dec 6, 2023
1 parent 6ea3fae commit 2a0dd39
Showing 1 changed file with 61 additions and 23 deletions.
84 changes: 61 additions & 23 deletions apps/web/src/components/TopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { MFALogoIcon, UserProfileAvatar } from 'apps/web/src/static/icons';
import { Box, Hide, IconButton, Text, Flex, Spacer } from '@chakra-ui/react';
import {
Box,
Hide,
IconButton,
Text,
Flex,
Spacer,
Button,
Popover,
PopoverBody,
PopoverContent,
PopoverTrigger,
} from '@chakra-ui/react';
import { useAuth } from '@web/hooks/useAuth';

export const TopBar: React.FC = () => {
const { user } = useAuth();
const { user, logout } = useAuth();

return (
<Flex
Expand Down Expand Up @@ -34,27 +46,53 @@ export const TopBar: React.FC = () => {
Welcome back, {user?.firstName}!
</Text>
</Hide>
<IconButton
pl="12px"
pr="40px"
aria-label="Visit profile"
icon={
user?.firstName && user?.lastName ? (
<UserProfileAvatar
firstName={user.firstName}
lastName={user.lastName}
boxSize={7}
/>
) : (
<UserProfileAvatar
firstName="Default"
lastName="User"
boxSize={7}
/>
)
}
colorScheme="none"
/>
<Spacer w="12px" />
<Popover placement="bottom-end">
<PopoverTrigger>
<IconButton
aria-label="Visit profile"
icon={
user?.firstName && user?.lastName ? (
<UserProfileAvatar
firstName={user.firstName}
lastName={user.lastName}
boxSize={7}
/>
) : (
<UserProfileAvatar
firstName="Default"
lastName="User"
boxSize={7}
/>
)
}
colorScheme="none"
/>
</PopoverTrigger>
<PopoverContent maxW="150px">
<PopoverBody>
<Box>
<Text
fontSize="17px"
fontWeight="700"
cursor="default"
pb="10px"
>
{user?.firstName + ' ' + user?.lastName}
</Text>
<Button
borderRadius="8px"
height="25px"
cursor="default"
onClick={logout}
>
Logout
</Button>
</Box>
</PopoverBody>
</PopoverContent>
</Popover>
<Spacer w="40px" />
</Flex>
</Flex>
);
Expand Down

0 comments on commit 2a0dd39

Please sign in to comment.