From 0d6d2769bd38980098663bc923e38c3b4e9233d6 Mon Sep 17 00:00:00 2001 From: camila-carrillo Date: Mon, 13 Oct 2025 16:56:07 -0400 Subject: [PATCH 1/4] route added to main page & beginning for my grants page --- frontend/src/main-page/MainPage.tsx | 2 + .../src/main-page/grants/MyGrantsPage.tsx | 47 +++++++++++++++++++ .../grants/grant-list/MyGrantList.tsx | 0 3 files changed, 49 insertions(+) create mode 100644 frontend/src/main-page/grants/MyGrantsPage.tsx create mode 100644 frontend/src/main-page/grants/grant-list/MyGrantList.tsx diff --git a/frontend/src/main-page/MainPage.tsx b/frontend/src/main-page/MainPage.tsx index 3796071..c1d71e3 100644 --- a/frontend/src/main-page/MainPage.tsx +++ b/frontend/src/main-page/MainPage.tsx @@ -3,6 +3,7 @@ import Dashboard from "./dashboard/Dashboard"; import GrantPage from "./grants/GrantPage"; import Header from "./header/Header"; import Users from "./users/Users"; +import MyGrantsPage from "./grants/MyGrantsPage"; function MainPage() { return ( @@ -11,6 +12,7 @@ function MainPage() { } /> } /> + } /> } /> {/* fallback route */} } /> diff --git a/frontend/src/main-page/grants/MyGrantsPage.tsx b/frontend/src/main-page/grants/MyGrantsPage.tsx new file mode 100644 index 0000000..282d3d6 --- /dev/null +++ b/frontend/src/main-page/grants/MyGrantsPage.tsx @@ -0,0 +1,47 @@ +import "./styles/GrantPage.css"; +import { useAuthContext } from "../../context/auth/authContext"; +import AddGrantButton from "./new-grant/AddGrant.tsx"; +import GrantSearch from "./filter-bar/GrantSearch.tsx"; +import NewGrantModal from "./new-grant/NewGrantModal.tsx"; +import { useState } from "react"; +import MyGrantList from "./grant-list/MyGrantList.tsx"; +import { Grant } from "../../../../middle-layer/types/Grant.ts"; +import FilterBar from "./filter-bar/FilterBar.tsx"; + +function MyGrantsPage() { + const [showNewGrantModal, setShowNewGrantModal] = useState(false); + const [selectedGrant, setSelectedGrant] = useState(null); + + const { user } = useAuthContext(); + const currentUserEmail = user?.email || ""; // safe fallback + + console.log("Current logged-in user:", user); + + return ( +
+
+ + setShowNewGrantModal(true)} /> +
+ +
+
+ +
+
+ setSelectedGrant(null)} + /> +
+
+ + {showNewGrantModal && ( + setShowNewGrantModal(false)} /> + )} +
+ ); +} + +export default MyGrantsPage; \ No newline at end of file diff --git a/frontend/src/main-page/grants/grant-list/MyGrantList.tsx b/frontend/src/main-page/grants/grant-list/MyGrantList.tsx new file mode 100644 index 0000000..e69de29 From 12ee2d69a35824c79fb4b358375a1774ca9da247 Mon Sep 17 00:00:00 2001 From: camila-carrillo Date: Thu, 16 Oct 2025 19:11:59 -0400 Subject: [PATCH 2/4] deleted mygrants page, modified mygrants route, initial filter logic --- frontend/src/main-page/MainPage.tsx | 6 +-- frontend/src/main-page/grants/GrantPage.tsx | 21 ++++++++- .../src/main-page/grants/MyGrantsPage.tsx | 47 ------------------- .../src/main-page/grants/grant-list/index.tsx | 21 +++++++-- 4 files changed, 41 insertions(+), 54 deletions(-) delete mode 100644 frontend/src/main-page/grants/MyGrantsPage.tsx diff --git a/frontend/src/main-page/MainPage.tsx b/frontend/src/main-page/MainPage.tsx index c1d71e3..872ea79 100644 --- a/frontend/src/main-page/MainPage.tsx +++ b/frontend/src/main-page/MainPage.tsx @@ -3,7 +3,7 @@ import Dashboard from "./dashboard/Dashboard"; import GrantPage from "./grants/GrantPage"; import Header from "./header/Header"; import Users from "./users/Users"; -import MyGrantsPage from "./grants/MyGrantsPage"; + function MainPage() { return ( @@ -11,8 +11,8 @@ function MainPage() {
} /> - } /> - } /> + } /> + } /> } /> {/* fallback route */} } /> diff --git a/frontend/src/main-page/grants/GrantPage.tsx b/frontend/src/main-page/grants/GrantPage.tsx index 047f8da..16133a7 100644 --- a/frontend/src/main-page/grants/GrantPage.tsx +++ b/frontend/src/main-page/grants/GrantPage.tsx @@ -7,11 +7,28 @@ import NewGrantModal from "./new-grant/NewGrantModal.tsx"; import { useState } from "react"; import { Grant } from "../../../../middle-layer/types/Grant.ts"; import FilterBar from "./filter-bar/FilterBar.tsx"; +import { useAuthContext } from "../../context/auth/authContext"; -function GrantPage() { +//can check route path to see if my-grants or all-grants and pass it in, only filter if equal to my grants +//or can pass in a parameter of user email and leave it empty to just show all grants, or my-grants if email +//no need to create an entirely new page since then if any design changes needed to be made they'd be needed to be made twice +//tell ben where you pass in user object so he can easily manipulate it once he actually passes the user object into the frontend +//add a mock user to the userstore to test the frontend since the frontend currently does not have the user object +interface GrantPageProps { + showOnlyMyGrants?: boolean; //if true, filters grants by user email +} + + +function GrantPage({ showOnlyMyGrants = false }: GrantPageProps) { const [showNewGrantModal, setShowNewGrantModal] = useState(false); const [selectedGrant, setSelectedGrant] = useState(null); + const { user } = useAuthContext(); //gets current logged in user + + const currentUserEmail = user?.email || ""; //safe fallback + + console.log("Current logged-in user:", user); + return (
@@ -31,6 +48,8 @@ function GrantPage() { selectedGrant ? selectedGrant.grantId : undefined } onClearSelectedGrant={() => setSelectedGrant(null)} + showOnlyMyGrants={showOnlyMyGrants} + currentUserEmail={currentUserEmail} />
diff --git a/frontend/src/main-page/grants/MyGrantsPage.tsx b/frontend/src/main-page/grants/MyGrantsPage.tsx deleted file mode 100644 index 282d3d6..0000000 --- a/frontend/src/main-page/grants/MyGrantsPage.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import "./styles/GrantPage.css"; -import { useAuthContext } from "../../context/auth/authContext"; -import AddGrantButton from "./new-grant/AddGrant.tsx"; -import GrantSearch from "./filter-bar/GrantSearch.tsx"; -import NewGrantModal from "./new-grant/NewGrantModal.tsx"; -import { useState } from "react"; -import MyGrantList from "./grant-list/MyGrantList.tsx"; -import { Grant } from "../../../../middle-layer/types/Grant.ts"; -import FilterBar from "./filter-bar/FilterBar.tsx"; - -function MyGrantsPage() { - const [showNewGrantModal, setShowNewGrantModal] = useState(false); - const [selectedGrant, setSelectedGrant] = useState(null); - - const { user } = useAuthContext(); - const currentUserEmail = user?.email || ""; // safe fallback - - console.log("Current logged-in user:", user); - - return ( -
-
- - setShowNewGrantModal(true)} /> -
- -
-
- -
-
- setSelectedGrant(null)} - /> -
-
- - {showNewGrantModal && ( - setShowNewGrantModal(false)} /> - )} -
- ); -} - -export default MyGrantsPage; \ No newline at end of file diff --git a/frontend/src/main-page/grants/grant-list/index.tsx b/frontend/src/main-page/grants/grant-list/index.tsx index cc48a11..0c715fd 100644 --- a/frontend/src/main-page/grants/grant-list/index.tsx +++ b/frontend/src/main-page/grants/grant-list/index.tsx @@ -7,19 +7,27 @@ import { ButtonGroup, IconButton, Pagination } from "@chakra-ui/react"; import { HiChevronLeft, HiChevronRight } from "react-icons/hi"; import { ProcessGrantData } from "../filter-bar/processGrantData.ts"; import NewGrantModal from "../new-grant/NewGrantModal.tsx"; +import { Grant } from "../../../../../middle-layer/types/Grant.ts"; const ITEMS_PER_PAGE = 6; interface GrantListProps { selectedGrantId?: number; onClearSelectedGrant?: () => void; + showOnlyMyGrants?: boolean; + currentUserEmail?: string; } -const GrantList: React.FC = observer(({ selectedGrantId, onClearSelectedGrant }) => { +const GrantList: React.FC = observer(({ selectedGrantId, onClearSelectedGrant, showOnlyMyGrants = false, currentUserEmail }) => { const { grants, onSort } = ProcessGrantData(); const [currentPage, setPage] = useState(1); const [showNewGrantModal, setShowNewGrantModal] = useState(false); + const displayedGrants = showOnlyMyGrants ? grants.filter( + (grant: Grant) => grant.bcan_poc?.POC_email?.toLowerCase() === currentUserEmail?.toLowerCase() + ) + : grants; + useEffect(() => { if (selectedGrantId !== undefined && grants.length > 0) { const index = grants.findIndex(grant => grant.grantId === Number(selectedGrantId)); @@ -32,10 +40,10 @@ const GrantList: React.FC = observer(({ selectedGrantId, onClear } }, [selectedGrantId, grants, currentPage]); - const count = grants.length; + const count = displayedGrants.length; const startRange = (currentPage - 1) * ITEMS_PER_PAGE; const endRange = startRange + ITEMS_PER_PAGE; - const visibleItems = grants.slice(startRange, endRange); + const visibleItems = displayedGrants.slice(startRange, endRange); return (
@@ -47,6 +55,13 @@ const GrantList: React.FC = observer(({ selectedGrantId, onClear grant={grant} defaultExpanded={grant.grantId === Number(selectedGrantId)} /> ))} + {visibleItems.length === 0 && ( +

+ {showOnlyMyGrants + ? "You currently have no grants assigned as BCAN POC." + : "No grants found>"} +

+ )}
Date: Fri, 17 Oct 2025 00:01:15 -0400 Subject: [PATCH 3/4] deleted comments --- frontend/src/main-page/grants/GrantPage.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/main-page/grants/GrantPage.tsx b/frontend/src/main-page/grants/GrantPage.tsx index 16133a7..331e2f2 100644 --- a/frontend/src/main-page/grants/GrantPage.tsx +++ b/frontend/src/main-page/grants/GrantPage.tsx @@ -9,11 +9,7 @@ import { Grant } from "../../../../middle-layer/types/Grant.ts"; import FilterBar from "./filter-bar/FilterBar.tsx"; import { useAuthContext } from "../../context/auth/authContext"; -//can check route path to see if my-grants or all-grants and pass it in, only filter if equal to my grants -//or can pass in a parameter of user email and leave it empty to just show all grants, or my-grants if email -//no need to create an entirely new page since then if any design changes needed to be made they'd be needed to be made twice -//tell ben where you pass in user object so he can easily manipulate it once he actually passes the user object into the frontend -//add a mock user to the userstore to test the frontend since the frontend currently does not have the user object + interface GrantPageProps { showOnlyMyGrants?: boolean; //if true, filters grants by user email } @@ -48,8 +44,8 @@ function GrantPage({ showOnlyMyGrants = false }: GrantPageProps) { selectedGrant ? selectedGrant.grantId : undefined } onClearSelectedGrant={() => setSelectedGrant(null)} - showOnlyMyGrants={showOnlyMyGrants} currentUserEmail={currentUserEmail} + showOnlyMyGrants={showOnlyMyGrants} /> From 4199705c137f8035ab6c9fc79c4f80403336ef73 Mon Sep 17 00:00:00 2001 From: prooflesben Date: Mon, 3 Nov 2025 21:22:55 -0500 Subject: [PATCH 4/4] Fixed merge issue --- .../src/main-page/grants/grant-list/index.tsx | 54 +------------------ 1 file changed, 1 insertion(+), 53 deletions(-) diff --git a/frontend/src/main-page/grants/grant-list/index.tsx b/frontend/src/main-page/grants/grant-list/index.tsx index 277fc24..9cd4e03 100644 --- a/frontend/src/main-page/grants/grant-list/index.tsx +++ b/frontend/src/main-page/grants/grant-list/index.tsx @@ -109,59 +109,7 @@ const GrantList: React.FC = observer(({ selectedGrantId, onClear setShowNewGrantModal(false)} /> )} - { - if (onClearSelectedGrant) { - onClearSelectedGrant(); - } - }} - onPageChange={(e) => { - setPage(e.page); - }} - > - - - - - - - - {({ pages }) => - pages.map((page, index) => - page.type === "page" ? ( - setPage(page.value)} - aria-label={`Go to page ${page.value}`} - > - {page.value} - - ) : ( - "..." - ) - ) - } - - - - - - - - - {showNewGrantModal && ( - setShowNewGrantModal(false)} /> - )} - + ); } );