-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVolunteerDashboard.tsx
57 lines (46 loc) · 1.66 KB
/
VolunteerDashboard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useEffect, useState } from "react";
import { Flex, Box, Heading } from "@chakra-ui/react";
import {Redirect} from "react-router-dom";
import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants";
import CustomizedCalendar from "./Calendar/CustomizedCalendar";
import Shifts from "./Shifts";
import NavBarVolunteer from "../common/NavBarVolunteer";
import { INVITE_PAGE } from "../../constants/Routes";
const VolunteerDashboard = (): React.ReactElement => {
const [userInfo, setUserInfo] = useState<any>({
firstName: "",
lastName: "",
role: "",
});
const [inviteShiftId, setInviteShiftId] = useState<string | null>(null);
useEffect(() => {
const userData = localStorage.getItem(AUTHENTICATED_USER_KEY);
const shiftId = localStorage.getItem('shiftId');
if (shiftId) {
setInviteShiftId(shiftId);
localStorage.removeItem('shiftId');
}
if (userData) {
const parsedUserData = JSON.parse(userData);
console.log(parsedUserData); // Remove this later
setUserInfo(parsedUserData);
}
}, []);
if (inviteShiftId) {
return <Redirect to={{pathname: INVITE_PAGE, search: `?shiftId=${inviteShiftId}`}} />
}
return (
<Flex direction="column" h="100vh">
<NavBarVolunteer firstName={userInfo.firstName} lastName={userInfo.lastName} role={userInfo.role}/>
<Flex flex="1">
<Box pt={10} pl={8} border="1px" borderColor="gray.100">
<Shifts />
</Box>
<Box flex="1" pt={10} pl={6} border="1px" borderColor="gray.100">
<CustomizedCalendar />
</Box>
</Flex>
</Flex>
);
};
export default VolunteerDashboard;