diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 4b79f7e..21fed6a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -33,6 +33,7 @@ import SignupEmergencyContact from "./components/auth/SignupEmergencyContact"; import SignupSecondary from "./components/auth/SignupSecondary"; import CustomizedCalendar from "./components/pages/Calendar/CustomizedCalendar"; import PlatformSignupRequests from "./components/pages/PlatformSignupRequests"; +import Invite from "./components/pages/Invite"; const App = (): React.ReactElement => { const currentUser: AuthenticatedUser = getLocalStorageObj( @@ -140,6 +141,11 @@ const App = (): React.ReactElement => { path={Routes.PLATFORM_SIGNUP_REQUESTS} component={PlatformSignupRequests} /> + diff --git a/frontend/src/components/auth/PrivateRoute.tsx b/frontend/src/components/auth/PrivateRoute.tsx index f020432..e59a6a4 100644 --- a/frontend/src/components/auth/PrivateRoute.tsx +++ b/frontend/src/components/auth/PrivateRoute.tsx @@ -1,5 +1,5 @@ import React, { useContext } from "react"; -import { Route, Redirect } from "react-router-dom"; +import { Route, Redirect, useLocation } from "react-router-dom"; import AuthContext from "../../contexts/AuthContext"; import { LOGIN_PAGE } from "../../constants/Routes"; @@ -17,11 +17,20 @@ const PrivateRoute: React.FC = ({ }: PrivateRouteProps) => { const { authenticatedUser } = useContext(AuthContext); - return authenticatedUser ? ( - - ) : ( - - ); + const location = useLocation(); + + const queryParams = new URLSearchParams(location.search); + const shiftId = queryParams.get('shiftId'); + + if (authenticatedUser) { + return + } + + if (shiftId) { + localStorage.setItem('shiftId', shiftId) + } + + return }; export default PrivateRoute; diff --git a/frontend/src/components/pages/Invite.tsx b/frontend/src/components/pages/Invite.tsx new file mode 100644 index 0000000..35dd230 --- /dev/null +++ b/frontend/src/components/pages/Invite.tsx @@ -0,0 +1,122 @@ +import React, { useEffect, useState } from "react"; +import { + Text, + Flex, + Table, + Thead, + Tbody, + Tr, + Th, + Td, + TableContainer, + Checkbox, + Badge, + IconButton, + Icon, +} from '@chakra-ui/react'; +import { FaCheck, FaXmark, FaSistrix, FaArrowsRotate, FaBars, FaAngleRight, FaAngleLeft } from "react-icons/fa6"; +import { useLocation } from 'react-router-dom' + +import NavBarAdmin from "../common/NavBarAdmin"; +import ServiceRequestAPIClient from "../../APIClients/ServiceRequestAPIClient"; +import NavBarVolunteer from "../common/NavBarVolunteer"; + +interface UserInfo { + id: string; + email: string; + firstName: string; + lastName: string; + status: string; + createdAt: string | null; +} + +const Invite = (): React.ReactElement => { + + const location = useLocation(); + + const queryParams = new URLSearchParams(location.search); + const id = queryParams.get('id'); + const [userInfo, setUserInfo] = useState([]); + + useEffect(() => { + console.log(id) + const fetchData = async () => { + try { + const response = await ServiceRequestAPIClient.getPlatformSignups(); + setUserInfo(response); + } catch (error) { + console.error("Error fetching platform signups:", error); + } + }; + fetchData(); + }, []); + + const [selectAll, setSelectAll] = useState(false); + const [checkedItems, setCheckedItems] = useState([]); + const [currentPage, setCurrentPage] = useState(1); + const itemsPerPage = 999; + + useEffect(() => { + setCheckedItems(new Array(userInfo.length).fill(false)); + }, [userInfo]); + + const handleSelectAllChange = () => { + const newSelectAll = !selectAll; + setSelectAll(newSelectAll); + setCheckedItems(new Array(userInfo.length).fill(newSelectAll)); + }; + + const handleCheckboxChange = (index: number) => { + const newCheckedItems = [...checkedItems]; + newCheckedItems[index] = !newCheckedItems[index]; + setCheckedItems(newCheckedItems); + setSelectAll(newCheckedItems.every(item => item)); + }; + + const getBadgeBg = (status: string): string => { + if (status === "PENDING") return '#DACFFB'; + return 'gray.200'; + }; + + const getBadgeColor = (status: string): string => { + if (status === "PENDING") return "#230282"; + return 'black'; + }; + + const handleApproveClick = () => { + console.log("Approve icon clicked"); + }; + + const handleRejectClick = () => { + console.log("Reject icon clicked"); + }; + + const handleSearchClick = () => { + console.log("Search icon clicked"); + }; + + const handleRefreshClick = () => { + console.log("Refresh icon clicked"); + }; + + const handleFilterClick = () => { + console.log("Filter icon clicked"); + }; + + const handlePageChange = (page: number) => { + setCurrentPage(page); + }; + + const totalPages = Math.ceil(userInfo.length / itemsPerPage); + const currentItems = userInfo.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage); + const itemCountStart = (currentPage - 1) * itemsPerPage + 1; + const itemCountEnd = Math.min(currentPage * itemsPerPage, userInfo.length); + + return ( +
+ Invite Page +
+ ); +}; + +export default Invite; \ No newline at end of file diff --git a/frontend/src/components/pages/VolunteerDashboard.tsx b/frontend/src/components/pages/VolunteerDashboard.tsx index 19c0e2b..5d56e2e 100644 --- a/frontend/src/components/pages/VolunteerDashboard.tsx +++ b/frontend/src/components/pages/VolunteerDashboard.tsx @@ -1,9 +1,11 @@ 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({ @@ -12,9 +14,16 @@ const VolunteerDashboard = (): React.ReactElement => { role: "", }); + + const [inviteShiftId, setInviteShiftId] = useState(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); @@ -24,6 +33,11 @@ const VolunteerDashboard = (): React.ReactElement => { } }, []); + if (inviteShiftId) { + return + } + + return ( diff --git a/frontend/src/constants/Routes.ts b/frontend/src/constants/Routes.ts index 0abfb1f..6e5c82a 100644 --- a/frontend/src/constants/Routes.ts +++ b/frontend/src/constants/Routes.ts @@ -31,3 +31,5 @@ export const SHIFTS_PAGE = "/shifts"; export const VOLUNTEER_DASHBOARD_PAGE = "/volunteer-dashboard"; export const PLATFORM_SIGNUP_REQUESTS = "/platform-signup-requests"; + +export const INVITE_PAGE = "/invite"