-
Notifications
You must be signed in to change notification settings - Fork 440
Add patent module dashboard UI components #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: patent-management-v1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: |
||
| "Assistant Professor", | ||
| "Research Engineer", | ||
| ].includes(role) | ||
| ) { | ||
| return <ApplicantMainDashboard />; | ||
| } | ||
|
|
||
| if (role === "Director") { | ||
| return <DirectorMainDashboard />; | ||
| } | ||
|
|
||
| if (role === "PCC Admin") { | ||
| return <PCCAdminMainDashboard />; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attorney role is missing and unreachable. This is the component actually wired into The Attorney branch does exist in Fix: Either add the Attorney branch here, or wire |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dead |
||
| }; | ||
|
|
||
| fetchData(); | ||
| }, [dispatch]); | ||
|
|
||
| return ( | ||
| <> | ||
| <CustomBreadcrumbs /> | ||
| <Flex justify="space-between" align="center" mt="lg"> | ||
| <ModuleTabs | ||
| tabs={tabItems} | ||
| activeTab={activeTab} | ||
| setActiveTab={setActiveTab} | ||
| badges={[]} | ||
| /> | ||
|
|
||
| <Flex align="center" mt="md" rowGap="1rem" columnGap="4rem" wrap="wrap"> | ||
| <Select | ||
| classNames={{ | ||
| option: "select-options", | ||
| input: "select-inputs", | ||
| }} | ||
| variant="filled" | ||
| leftSection={<SortAscending />} | ||
| data={categories} | ||
| value={sortedBy} | ||
| onChange={setSortedBy} | ||
| placeholder="Sort By" | ||
| /> | ||
| </Flex> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort dropdown has no effect on data. |
||
| </Flex> | ||
|
|
||
| {/* Render content based on the active tab */} | ||
| <Grid mt="xl"> | ||
| {loading ? ( | ||
| <Container py="xl"> | ||
| <Loader size="lg" /> | ||
| </Container> | ||
| ) : ( | ||
| <> | ||
| {activeTab === "0" && ( | ||
| <ApplicantDashboard setActiveTab={setActiveTab} /> | ||
| )} | ||
| {activeTab === "1" && ( | ||
| <SubmitNewApplication setActiveTab={setActiveTab} /> | ||
| )} | ||
| {activeTab === "1.1" && ( | ||
| <ApplicationForm setActiveTab={setActiveTab} /> | ||
| )} | ||
| {activeTab === "2" && ( | ||
| <ViewApplicationsPage setActiveTab={setActiveTab} /> | ||
| )} | ||
| {activeTab === "3" && ( | ||
| <SavedDraftsPage setActiveTab={setActiveTab} /> | ||
| )} | ||
| {activeTab === "4" && ( | ||
| <NotificationsPage setActiveTab={setActiveTab} /> | ||
| )} | ||
| </> | ||
| )} | ||
| </Grid> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default ApplicantMainDashboard; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasTokenis captured once at mount and goes stale.Boolean(localStorage.getItem('authToken'))is evaluated whenAppfirst renders. If the token is added or removed later in the session (e.g. after login without a full page reload),hasTokenkeeps its initial value and<ValidateAuth />/<InactivityHandler />will behave incorrectly. Prefer deriving this from Redux auth state so it re-renders reactively.