Skip to content

Commit 6f4f125

Browse files
committed
adding navbar to admin dashboard
1 parent 95f42e5 commit 6f4f125

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

frontend/src/components/common/NavBarAdmin.tsx

+28-41
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ import {
1010
Image,
1111
Spacer,
1212
Avatar,
13+
Button,
1314
Icon,
15+
Popover,
16+
PopoverTrigger,
17+
PopoverContent,
18+
PopoverHeader,
19+
PopoverBody,
20+
PopoverFooter,
21+
PopoverArrow,
22+
PopoverCloseButton,
23+
PopoverAnchor
1424
} from '@chakra-ui/react';
1525
import { Link as ReactRouterLink, useLocation } from 'react-router-dom';
1626
import { BsPerson } from 'react-icons/bs';
@@ -19,7 +29,13 @@ import { PiBell } from "react-icons/pi";
1929
import { GoHome } from "react-icons/go";
2030
import abtc_logo from '../../images/abtc_logo.png';
2131

22-
const NavBarAdmin: React.FC = () => {
32+
interface NavBarAdminProps {
33+
firstName: string;
34+
lastName: string;
35+
role: string;
36+
}
37+
38+
const NavBarAdmin: React.FC<NavBarAdminProps> = ({firstName, lastName, role}) => {
2339
const location = useLocation();
2440

2541
return (
@@ -96,50 +112,21 @@ const NavBarAdmin: React.FC = () => {
96112
color="#444750"
97113
fontWeight="500"
98114
_hover={{ color: "black", textDecoration: "none" }}
115+
paddingRight={4}
99116
>
100117
<Icon as={PiBell} boxSize={6} />
101118
</ChakraLink>
102-
<Box ml={6} mr={2}>
103-
<ChakraLink as={ReactRouterLink} to="/user-profile" fontWeight="bold" lineHeight="1.5">
104-
<Avatar size="md" name="User" src="https://placehold.co/25x25" />
105-
</ChakraLink>
106-
</Box>
119+
107120
<Box>
108-
<Menu>
109-
<MenuButton
110-
as={Box}
111-
color="#444750"
112-
fontWeight="500"
113-
_hover={{ color: "black", textDecoration: "none" }}
114-
>
115-
<Flex align="center">
116-
<Box ml={2}>
117-
Name-First-Last
118-
</Box>
119-
<Icon as={RxChevronDown} boxSize={6} ml={2} mr={2}/>
120-
</Flex>
121-
</MenuButton>
122-
<MenuList bg="white" border="none" minW="auto" w="auto">
123-
<MenuItem
124-
as={ReactRouterLink}
125-
to="/profile/placeholder"
126-
color="#444750"
127-
fontWeight="500"
128-
_hover={{ color: "black", textDecoration: "none" }}
129-
>
130-
Placeholder
131-
</MenuItem>
132-
<MenuItem
133-
as={ReactRouterLink}
134-
to="/profile/placeholder1"
135-
color="#444750"
136-
fontWeight="500"
137-
_hover={{ color: "black", textDecoration: "none" }}
138-
>
139-
Placeholder 2
140-
</MenuItem>
141-
</MenuList>
142-
</Menu>
121+
<Popover trigger="hover" placement="bottom-end">
122+
<PopoverTrigger>
123+
<Avatar size="md" name="User" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSNfBG0r9nBON7QsYexKnLDtTnn4bjfuWZyDndX4OuZPwJTtPUA" />
124+
</PopoverTrigger>
125+
<PopoverContent maxW="200px">
126+
<PopoverHeader>{firstName} {lastName}</PopoverHeader>
127+
<PopoverBody>Role: {role}</PopoverBody>
128+
</PopoverContent>
129+
</Popover>
143130
</Box>
144131
</Flex>
145132
);

frontend/src/components/pages/PlatformSignupRequests.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Icon,
1616
} from '@chakra-ui/react';
1717
import { FaCheck, FaXmark, FaSistrix, FaArrowsRotate, FaBars, FaAngleRight, FaAngleLeft } from "react-icons/fa6";
18+
import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants";
1819

1920
import NavBarAdmin from "../common/NavBarAdmin";
2021
import ServiceRequestAPIClient from "../../APIClients/ServiceRequestAPIClient";
@@ -30,8 +31,22 @@ interface UserInfo {
3031

3132
const PlatformSignupRequests = (): React.ReactElement => {
3233
const [userInfo, setUserInfo] = useState<UserInfo[]>([]);
34+
const [activeUser, setActiveUser] = useState<any>({
35+
firstName: "",
36+
lastName: "",
37+
role: "",
38+
});
3339

3440
useEffect(() => {
41+
const activeUserData = localStorage.getItem(AUTHENTICATED_USER_KEY);
42+
43+
if (activeUserData) {
44+
const parsedUserData = JSON.parse(activeUserData);
45+
console.log(parsedUserData); // Remove this later
46+
47+
setActiveUser(parsedUserData);
48+
}
49+
3550
const fetchData = async () => {
3651
try {
3752
const response = await ServiceRequestAPIClient.getPlatformSignups();
@@ -106,7 +121,7 @@ const PlatformSignupRequests = (): React.ReactElement => {
106121

107122
return (
108123
<Flex direction="column" h="100vh" ml="20" mr="20">
109-
<NavBarAdmin />
124+
<NavBarAdmin firstName={activeUser.firstName} lastName={activeUser.lastName} role={activeUser.role}/>
110125
<Text mt="10" fontSize='2xl'>Manage Accounts</Text>
111126

112127
<TableContainer mt='5' border='1px' borderColor='gray.200' borderRadius='20'>

0 commit comments

Comments
 (0)