Skip to content
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

RSVP Flow (Display the AcceptRSVPForm) #285

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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