-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- View profile picture if available - View details if available
- Loading branch information
Showing
2 changed files
with
134 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import React from "react"; | ||
import { auth, firestore } from "@/firebase/clientApp"; | ||
import { useAuthState } from "react-firebase-hooks/auth"; | ||
import { | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalCloseButton, | ||
ModalBody, | ||
ModalFooter, | ||
Button, | ||
Box, | ||
Text, | ||
Flex, | ||
Image, | ||
Icon, | ||
Stack, | ||
} from "@chakra-ui/react"; | ||
import { MdAccountCircle } from "react-icons/md"; | ||
import { User } from "@firebase/auth"; | ||
|
||
type ProfileModalProps = { | ||
open: boolean; | ||
handleClose: () => void; | ||
}; | ||
|
||
const ProfileModal: React.FC<ProfileModalProps> = ({ open, handleClose }) => { | ||
const [user] = useAuthState(auth); | ||
|
||
return ( | ||
<> | ||
<Modal isOpen={open} onClose={handleClose}> | ||
<ModalOverlay /> | ||
<ModalContent borderRadius={10}> | ||
<ModalHeader | ||
display="flex" | ||
flexDirection="column" | ||
padding={3} | ||
textAlign="center" | ||
> | ||
Profile | ||
</ModalHeader> | ||
<Box> | ||
<ModalCloseButton /> | ||
<ModalBody display="flex" flexDirection="column" padding="10px 0px"> | ||
<Stack p={5} spacing={5}> | ||
<ProfileModalPicture user={user} /> | ||
<ProfileModalUserDetails user={user} /> | ||
</Stack> | ||
</ModalBody> | ||
</Box> | ||
|
||
<ModalFooter bg="gray.100" borderRadius="0px 0px 10px 10px"> | ||
<Button | ||
variant="outline" | ||
height="30px" | ||
mr={3} | ||
onClick={handleClose} | ||
> | ||
B1 | ||
</Button> | ||
<Button height="30px">B2</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
export default ProfileModal; | ||
|
||
type ProfileModalPictureProps = { | ||
user: User | null | undefined; | ||
}; | ||
|
||
const ProfileModalPicture: React.FC<ProfileModalPictureProps> = ({ user }) => { | ||
return ( | ||
<Flex align="center" justify="center" p={2}> | ||
{user?.photoURL ? ( | ||
<Image | ||
src={user.photoURL} | ||
alt="User Profile Photo" | ||
height="120px" | ||
borderRadius="full" | ||
shadow="md" | ||
/> | ||
) : ( | ||
<Icon fontSize={120} mr={1} color="gray.300" as={MdAccountCircle} /> | ||
)} | ||
</Flex> | ||
); | ||
}; | ||
|
||
interface ProfileModalUserDetailsProps { | ||
user: User | null | undefined; | ||
} | ||
|
||
const ProfileModalUserDetails: React.FC<ProfileModalUserDetailsProps> = ({ | ||
user, | ||
}) => { | ||
return ( | ||
<Flex direction="column"> | ||
<Stack direction="row"> | ||
<Text fontWeight={700}>Display Name:</Text> | ||
<Text>{user?.displayName ? user.displayName : "No Name"}</Text> | ||
</Stack> | ||
<Stack direction="row"> | ||
<Text fontWeight={700}>Email:</Text> | ||
<Text>{user?.email}</Text> | ||
</Stack> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters