From a90a54e783094c3db0503d5036d964e009213fc9 Mon Sep 17 00:00:00 2001 From: miguelaenlle Date: Sun, 2 Feb 2025 11:40:55 -0600 Subject: [PATCH 1/2] Returned AcceptRSVPForm when handleConfirm is called; handleDecline refreshes the page after API call --- app/profile/page.tsx | 34 +++++++++++++++++-- .../Profile/RSVP/ModalViews/Accepted.tsx | 25 +++++++++++--- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/app/profile/page.tsx b/app/profile/page.tsx index 9485cdf5..d6d096a2 100644 --- a/app/profile/page.tsx +++ b/app/profile/page.tsx @@ -111,6 +111,18 @@ const Profile: React.FC = () => { }); }, [pathname, router]); + useEffect(() => { + // Ensure that the background content does not scroll + // when the modal is displayed + if (modalOpen) { + document.body.style.overflow = "hidden"; + document.documentElement.style.overflow = "hidden"; + } else { + document.body.style.overflow = "unset"; + document.documentElement.style.overflow = "unset"; + } + }, [modalOpen]); + return ( <> {isLoading && } @@ -145,6 +157,7 @@ const Profile: React.FC = () => { isProApplicant={isProApplicant} qrUrl={qrCodeURL} reimburse={RSVP.reimbursementValue} + onRequestClose={() => setModalOpen(false)} /> @@ -266,6 +279,7 @@ type ModalContentProps = { isProApplicant: boolean; qrUrl: string | null; reimburse: number; + onRequestClose: () => void; }; const ModalContent: React.FC = ({ @@ -274,7 +288,8 @@ const ModalContent: React.FC = ({ isPro, isProApplicant, qrUrl, - reimburse + reimburse, + onRequestClose }) => { switch (status) { case "ACCEPTED": @@ -283,7 +298,13 @@ const ModalContent: React.FC = ({ } if (isPro) { - return ; + return ( + + ); } if (isProApplicant) { @@ -291,11 +312,18 @@ const ModalContent: React.FC = ({ ); } - return ; + return ( + + ); case "REJECTED": return ; case "WAITLISTED": diff --git a/components/Profile/RSVP/ModalViews/Accepted.tsx b/components/Profile/RSVP/ModalViews/Accepted.tsx index 9fa46f2f..91937417 100644 --- a/components/Profile/RSVP/ModalViews/Accepted.tsx +++ b/components/Profile/RSVP/ModalViews/Accepted.tsx @@ -1,24 +1,39 @@ -import React from "react"; -import styles from "./styles.module.scss"; +import AcceptRSVPForm from "@/components/AcceptRSVPForm/AcceptRSVPForm"; import OlympianButton from "@/components/OlympianButton/OlympianButton"; -import { RSVPDecideAccept, RSVPDecideDecline } from "@/util/api"; +import { RSVPDecideDecline } from "@/util/api"; +import { useState } from "react"; +import styles from "./styles.module.scss"; type AcceptedType = "PRO" | "PRO_TO_GENERAL" | "GENERAL"; type AcceptedProps = { acceptedType: AcceptedType; reimburse: number; + onRequestClose: () => void; }; -export default function Accepted({ acceptedType, reimburse }: AcceptedProps) { +export default function Accepted({ + acceptedType, + reimburse, + onRequestClose +}: AcceptedProps) { + const [accepted, setAccepted] = useState(false); const handleConfirm = async () => { - await RSVPDecideAccept(); + // TODO: Add a loading state and disable the buttons while loadingc + // await RSVPDecideAccept(); + setAccepted(true); }; const handleDecline = async () => { + // TODO: Add a loading state and disable the buttons while loading await RSVPDecideDecline(); + window.location.reload(); }; + if (accepted) { + return ; + } + return ( Date: Sun, 2 Feb 2025 11:41:44 -0600 Subject: [PATCH 2/2] Re-added decide accept API call --- components/Profile/RSVP/ModalViews/Accepted.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/Profile/RSVP/ModalViews/Accepted.tsx b/components/Profile/RSVP/ModalViews/Accepted.tsx index 91937417..1d40b660 100644 --- a/components/Profile/RSVP/ModalViews/Accepted.tsx +++ b/components/Profile/RSVP/ModalViews/Accepted.tsx @@ -1,6 +1,6 @@ import AcceptRSVPForm from "@/components/AcceptRSVPForm/AcceptRSVPForm"; import OlympianButton from "@/components/OlympianButton/OlympianButton"; -import { RSVPDecideDecline } from "@/util/api"; +import { RSVPDecideAccept, RSVPDecideDecline } from "@/util/api"; import { useState } from "react"; import styles from "./styles.module.scss"; @@ -19,8 +19,8 @@ export default function Accepted({ }: AcceptedProps) { const [accepted, setAccepted] = useState(false); const handleConfirm = async () => { - // TODO: Add a loading state and disable the buttons while loadingc - // await RSVPDecideAccept(); + // TODO: Add a loading state and disable the buttons while loading + await RSVPDecideAccept(); setAccepted(true); };