| 16 | import NavSidebarOption from "./NavSidebarOption"; |
| 17 | |
| 18 | export default function UserMenu({ user, ...rest }: { user: Session } & StackProps) { |
| 19 | const profileImage = user.user.image ? ( |
| 20 | <Image src={user.user.image} alt="profile picture" boxSize={8} borderRadius="50%" /> |
| 21 | ) : ( |
| 22 | <Icon as={BsPersonCircle} boxSize={6} /> |
| 23 | ); |
| 24 | |
| 25 | return ( |
| 26 | <Popover placement="right"> |
| 27 | <PopoverTrigger> |
| 28 | <NavSidebarOption> |
| 29 | <HStack |
| 30 | // Weird values to make mobile look right; can clean up when we make the sidebar disappear on mobile |
| 31 | py={2} |
| 32 | px={1} |
| 33 | spacing={3} |
| 34 | {...rest} |
| 35 | > |
| 36 | {profileImage} |
| 37 | <VStack spacing={0} align="start" flex={1} flexShrink={1}> |
| 38 | <Text fontWeight="bold" fontSize="sm"> |
| 39 | {user.user.name} |
| 40 | </Text> |
| 41 | <Text color="gray.500" fontSize="xs"> |
| 42 | {/* {user.user.email} */} |
| 43 | </Text> |
| 44 | </VStack> |
| 45 | <Icon as={BsChevronRight} boxSize={4} color="gray.500" /> |
| 46 | </HStack> |
| 47 | </NavSidebarOption> |
| 48 | </PopoverTrigger> |
| 49 | <PopoverContent _focusVisible={{ outline: "unset" }} ml={-1} minW={48} w="full"> |
| 50 | <VStack align="stretch" spacing={0}> |
| 51 | {/* sign out */} |
| 52 | <HStack |
| 53 | as={Link} |
| 54 | onClick={() => { |
| 55 | signOut().catch(console.error); |
| 56 | }} |
| 57 | px={4} |
| 58 | py={2} |
| 59 | spacing={4} |
| 60 | color="gray.500" |
| 61 | fontSize="sm" |
| 62 | > |
| 63 | <Icon as={BsBoxArrowRight} boxSize={6} /> |
| 64 | <Text>Sign out</Text> |
| 65 | </HStack> |
| 66 | </VStack> |
| 67 | </PopoverContent> |
| 68 | </Popover> |
| 69 | ); |
| 70 | } |