From 9160e5149d4594f8e23fbeed8850d43aa2a0f5d8 Mon Sep 17 00:00:00 2001 From: Garrett Rabian <57802560+gmrabian@users.noreply.github.com> Date: Wed, 20 Mar 2024 11:41:13 -0400 Subject: [PATCH] Add pagination ability (#192) * add pagination ability; needs rework with filters * remove icon * fixup filtering and tests --- src/app/[id]/apply/confirmation/page.tsx | 13 +- src/app/[id]/page.tsx | 14 +- src/app/assets/icons/arrow_upward.svg | 10 -- src/app/components/cards/BannerCard.tsx | 7 +- src/app/components/form/AppForm.tsx | 10 +- src/app/components/layout/Browse.tsx | 123 ++++++++++------ src/app/components/modals/FilterModal.tsx | 13 +- src/app/styles/browse.scss | 15 +- .../jest/frontend/ConfirmationPage.test.tsx | 3 + .../jest/frontend/DetailsPage.test.tsx | 2 +- .../testing/jest/frontend/Homepage.test.tsx | 23 ++- .../components/cards/BannerCard.test.tsx | 2 +- .../frontend/utils/libs/dynamodb-lib.test.ts | 7 + src/app/utils/filtering.ts | 2 +- src/app/utils/institutions.ts | 132 +++++++++++------- src/app/utils/libs/dynamodb-lib.ts | 3 + 16 files changed, 240 insertions(+), 139 deletions(-) delete mode 100644 src/app/assets/icons/arrow_upward.svg diff --git a/src/app/[id]/apply/confirmation/page.tsx b/src/app/[id]/apply/confirmation/page.tsx index f99c799..14eb5e0 100644 --- a/src/app/[id]/apply/confirmation/page.tsx +++ b/src/app/[id]/apply/confirmation/page.tsx @@ -11,20 +11,17 @@ import ErrorPage from "@/src/app/error/page"; // types import { College } from "@/src/app/types"; -const filterCollege = (institutionsArray: College[], id: number) => { - return institutionsArray.filter((college) => college.id == id)[0]; -}; - export default function ConfirmationPage({ params }: Props) { - const { institutionsArray } = useContext(InstitutionContext); + const { institutionsObject } = useContext(InstitutionContext); const [loading, setLoading] = useState(true); const [selectedCollege, setSelectedCollege] = useState(); + useEffect(() => { - if (institutionsArray) { - setSelectedCollege(filterCollege(institutionsArray!, params.id)); + if (institutionsObject) { + setSelectedCollege(institutionsObject[params.id]); setLoading(false); } - }, [institutionsArray, params.id]); + }, [institutionsObject, params.id]); const View = !selectedCollege ? ( diff --git a/src/app/[id]/page.tsx b/src/app/[id]/page.tsx index 507b105..065ccf9 100644 --- a/src/app/[id]/page.tsx +++ b/src/app/[id]/page.tsx @@ -11,30 +11,26 @@ import NotFound from "@/src/app/not-found"; // types import { College } from "../types"; -const filterCollege = (institutionsArray: College[], id: number) => { - return institutionsArray.filter((college) => college.id == id)[0]; -}; - export default function InstitutionDetails({ params, }: { params: { id: number }; }) { - const { institutionsArray } = useContext(InstitutionContext); + const { institutionsObject } = useContext(InstitutionContext); const [loading, setLoading] = useState(true); const [selectedCollege, setSelectedCollege] = useState(); useEffect(() => { - if (institutionsArray) { - setSelectedCollege(filterCollege(institutionsArray!, params.id)); + if (institutionsObject) { + setSelectedCollege(institutionsObject[params.id]); setLoading(false); } - }, [institutionsArray, params.id]); + }, [institutionsObject, params.id]); const View = !selectedCollege ? ( ) : (
    - +
); diff --git a/src/app/assets/icons/arrow_upward.svg b/src/app/assets/icons/arrow_upward.svg deleted file mode 100644 index 3c4ac73..0000000 --- a/src/app/assets/icons/arrow_upward.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/src/app/components/cards/BannerCard.tsx b/src/app/components/cards/BannerCard.tsx index a35e18d..1629830 100644 --- a/src/app/components/cards/BannerCard.tsx +++ b/src/app/components/cards/BannerCard.tsx @@ -21,13 +21,13 @@ import { //types import { College } from "../../types"; -export const BannerCard = ({ college }: Props) => { +export const BannerCard = ({ college, id }: Props) => { return (
{ mixpanel.track("click_launch-application")} aria-label={`Apply to ${college.name}`} > @@ -79,4 +79,5 @@ export const BannerCard = ({ college }: Props) => { type Props = { college: College; + id: number; }; diff --git a/src/app/components/form/AppForm.tsx b/src/app/components/form/AppForm.tsx index e9d5da0..7e1b093 100644 --- a/src/app/components/form/AppForm.tsx +++ b/src/app/components/form/AppForm.tsx @@ -76,7 +76,7 @@ export const AppForm = ({ institutionId }: Props) => { const ApplicationView = !application ? ( ) : ( -
+
{