diff --git a/src/App.jsx b/src/App.jsx index 99d55a675..fc136eb48 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2,6 +2,7 @@ import { createTheme, MantineProvider } from "@mantine/core"; import "@mantine/core/styles.css"; import "@mantine/notifications/styles.css"; import { Route, Routes, Navigate, useLocation } from "react-router-dom"; +import PropTypes from "prop-types"; import { Notifications } from "@mantine/notifications"; import { Layout } from "./components/layout"; import Dashboard from "./Modules/Dashboard/dashboardNotifications"; @@ -15,6 +16,7 @@ import InactivityHandler from "./helper/inactivityhandler"; import Examination from "./Modules/Examination/examination"; import Database from "./Modules/Database/database"; import ProgrammeCurriculumRoutes from "./Modules/Program_curriculum/programmCurriculum"; +import PatentModulePage from "./Modules/Patent/PatentModulePage"; import NotFoundPage from "./components/NotFoundPage"; const theme = createTheme({ @@ -28,60 +30,127 @@ const theme = createTheme({ }, }); +function RequireAuth({ children }) { + const currentLocation = useLocation(); + const token = localStorage.getItem("authToken"); + + if (!token) { + return ( + + ); + } + + return children; +} + +RequireAuth.propTypes = { + children: PropTypes.node.isRequired, +}; + export default function App() { const location = useLocation(); + const hasToken = Boolean(localStorage.getItem("authToken")); + return ( - {location.pathname !== "/accounts/login" && } - {location.pathname !== "/accounts/login" && } + {location.pathname !== "/accounts/login" && hasToken && } + {location.pathname !== "/accounts/login" && hasToken && ( + + )} - } /> + + } + /> - - + + + + + } /> - - + + + + + } /> - - + + + + + } /> - - + + + + + } /> - - + +
+ +
+
+ } + /> + + + + + } /> } /> } /> - } /> - } /> + + + + } + /> + + + + } + /> } />
diff --git a/src/Modules/Patent/PatentModulePage.jsx b/src/Modules/Patent/PatentModulePage.jsx new file mode 100644 index 000000000..6b0c988b3 --- /dev/null +++ b/src/Modules/Patent/PatentModulePage.jsx @@ -0,0 +1,31 @@ +import { useSelector } from "react-redux"; +import ApplicantMainDashboard from "./components/Applicant/ApplicantMainDashboard"; +import DirectorMainDashboard from "./components/Director/DirectorMainDashboard"; +import PCCAdminMainDashboard from "./components/PCCAdmin/PCCAdminMainDashboard"; + +export default function PatentModulePage() { + const role = useSelector((state) => state.user.role); + + if ( + [ + "student", + "alumini", + "Professor", + "Associate Professor", + "Assistant Professor", + "Research Engineer", + ].includes(role) + ) { + return ; + } + + if (role === "Director") { + return ; + } + + if (role === "PCC Admin") { + return ; + } + + return null; +} diff --git a/src/Modules/Patent/components/Applicant/ApplicantMainDashboard.jsx b/src/Modules/Patent/components/Applicant/ApplicantMainDashboard.jsx new file mode 100644 index 000000000..78c872a01 --- /dev/null +++ b/src/Modules/Patent/components/Applicant/ApplicantMainDashboard.jsx @@ -0,0 +1,109 @@ +import React, { useEffect, useState } from "react"; +import { Grid, Container, Loader, Flex, Select } from "@mantine/core"; +import { useDispatch } from "react-redux"; +import { SortAscending } from "@phosphor-icons/react"; +import CustomBreadcrumbs from "../../../../components/Breadcrumbs.jsx"; +import ModuleTabs from "../../../../components/moduleTabs.jsx"; +import SubmitNewApplication from "./SubmitNewApplication/ApplicantSubmit.jsx"; +import ApplicantDashboard from "./Dashboard/ApplicantDashboard.jsx"; +import ViewApplicationsPage from "./ViewApplication/ApplicationView.jsx"; +import SavedDraftsPage from "./SavedDrafts/ApplicationDraft.jsx"; +import NotificationsPage from "./Notifications/ApplicantNotifications.jsx"; +import ApplicationForm from "./SubmitNewApplication/ApplicationForm.jsx"; + +const categories = ["Most Recent", "Tags", "Title"]; + +function ApplicantMainDashboard() { + const [activeTab, setActiveTab] = useState("0"); + const [sortedBy, setSortedBy] = useState("Most Recent"); + const [loading, setLoading] = useState(false); + const dispatch = useDispatch(); + + // Define your tabs here + const tabItems = [ + { title: "Dashboard" }, + { title: "Submit New Application" }, + { title: "View Applications" }, + { title: "Saved Drafts" }, + { title: "Notifications" }, + ]; + + useEffect(() => { + const fetchData = async () => { + const token = localStorage.getItem("authToken"); + if (!token) return console.error("No authentication token found!"); + + try { + setLoading(true); + // Fetch data logic here if needed + } catch (error) { + console.error("Error fetching data:", error); + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [dispatch]); + + return ( + <> + + + + + +