Skip to content

Commit

Permalink
RSVP Flow (Display the AcceptRSVPForm) (#285)
Browse files Browse the repository at this point in the history
* Returned AcceptRSVPForm when handleConfirm is called; handleDecline refreshes the page after API call

* Re-added decide accept API call
  • Loading branch information
miguelaenlle authored Feb 5, 2025
1 parent f5be26d commit a6c84d0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
34 changes: 31 additions & 3 deletions app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 && <Loading />}
Expand Down Expand Up @@ -145,6 +157,7 @@ const Profile: React.FC = () => {
isProApplicant={isProApplicant}
qrUrl={qrCodeURL}
reimburse={RSVP.reimbursementValue}
onRequestClose={() => setModalOpen(false)}
/>
</div>
</Modal>
Expand Down Expand Up @@ -266,6 +279,7 @@ type ModalContentProps = {
isProApplicant: boolean;
qrUrl: string | null;
reimburse: number;
onRequestClose: () => void;
};

const ModalContent: React.FC<ModalContentProps> = ({
Expand All @@ -274,7 +288,8 @@ const ModalContent: React.FC<ModalContentProps> = ({
isPro,
isProApplicant,
qrUrl,
reimburse
reimburse,
onRequestClose
}) => {
switch (status) {
case "ACCEPTED":
Expand All @@ -283,19 +298,32 @@ const ModalContent: React.FC<ModalContentProps> = ({
}

if (isPro) {
return <Accepted acceptedType={"PRO"} reimburse={reimburse} />;
return (
<Accepted
acceptedType={"PRO"}
reimburse={reimburse}
onRequestClose={onRequestClose}
/>
);
}

if (isProApplicant) {
return (
<Accepted
acceptedType={"PRO_TO_GENERAL"}
reimburse={reimburse}
onRequestClose={onRequestClose}
/>
);
}

return <Accepted acceptedType={"GENERAL"} reimburse={reimburse} />;
return (
<Accepted
acceptedType={"GENERAL"}
reimburse={reimburse}
onRequestClose={onRequestClose}
/>
);
case "REJECTED":
return <Rejected />;
case "WAITLISTED":
Expand Down
21 changes: 18 additions & 3 deletions components/Profile/RSVP/ModalViews/Accepted.tsx
Original file line number Diff line number Diff line change
@@ -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 { 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 () => {
// TODO: Add a loading state and disable the buttons while loading
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 <AcceptRSVPForm closeModal={onRequestClose} />;
}

return (
<ChooseRSVP
acceptedType={acceptedType}
Expand Down

0 comments on commit a6c84d0

Please sign in to comment.