diff --git a/app/page.tsx b/app/page.tsx index 7b745378..8b7b5837 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,34 +1,19 @@ import React from "react"; import styles from "./page.module.scss"; -// import Olympian from "@/components/Home/Olympian/Olympian"; -// import Footer from "@/components/Home/Footer/Footer"; -// import FAQJoinUs from "@/components/Home/FAQJoinUs/FAQJoinUs"; -// import Sponsors from "@/components/Home/Sponsors/Sponsors"; -// import FAQSection from "@/components/Home/FAQ/FAQ"; -import Accepted from "@/components/Profile/RSVP/ModalViews/Accepted"; -import Rejected from "@/components/Profile/RSVP/ModalViews/Rejected"; -import ConfirmReject from "@/components/Profile/RSVP/ModalViews/ConfirmReject"; +import Olympian from "@/components/Home/Olympian/Olympian"; +import Footer from "@/components/Home/Footer/Footer"; +import FAQJoinUs from "@/components/Home/FAQJoinUs/FAQJoinUs"; +import Sponsors from "@/components/Home/Sponsors/Sponsors"; +import FAQSection from "@/components/Home/FAQ/FAQ"; const Home: React.FC = () => { return (
- {}} - handleGoBack={() => {}} - /> - {}} - handleDecline={() => {}} - > - Congrats, stuff is happening - - {}} /> - {/* + -
); }; diff --git a/app/profile/page.tsx b/app/profile/page.tsx index b14c38b1..9485cdf5 100644 --- a/app/profile/page.tsx +++ b/app/profile/page.tsx @@ -21,10 +21,11 @@ import { QRCodeSVG } from "qrcode.react"; import Modal from "react-modal"; import OlympianButton from "@/components/OlympianButton/OlympianButton"; import useWindowSize from "@/hooks/use-window-size"; -import UserRejected from "@/components/RSVPContent/UserRejected"; -import UserGeneralAcceptedToGeneral from "@/components/RSVPContent/UserGeneralAcceptedToGeneral"; -import UserProAcceptedToGeneral from "@/components/RSVPContent/UserProAcceptedToGeneral"; -import UserProAcceptedToPro from "@/components/RSVPContent/UserProAcceptedToPro"; +import { + Rejected, + Waitlisted +} from "@/components/Profile/RSVP/ModalViews/Rejected"; +import Accepted from "@/components/Profile/RSVP/ModalViews/Accepted"; type ValueItemProps = { label: string; @@ -47,6 +48,7 @@ const ValueItem: React.FC = ({ label, isHighlighted }) => { const Profile: React.FC = () => { const pathname = usePathname(); const router = useRouter(); + const windowSizeHook = useWindowSize(); const [registration, setRegistration] = useState( null @@ -56,24 +58,31 @@ const Profile: React.FC = () => { const [isLoading, setIsLoading] = useState(true); const [qrCodeURL, setQRCodeURL] = useState(null); - const [qrCodeOpen, setQRCodeOpen] = useState(false); - const [detailsOpen, setDetailsOpen] = useState(false); - const handleOpenQRCode = async () => { - const qrCode = await getQRCode(); - setQRCodeURL(qrCode); - setQRCodeOpen(true); - }; + const [modalOpen, setModalOpen] = useState(false); - const handleSetDetailsOpen = () => { - setDetailsOpen(true); - }; + const getButtonText = () => { + if (RSVP?.status === "REJECTED" || RSVP?.status === "WAITLISTED") { + return "Details"; + } - const handleCloseQRCode = () => { - setQRCodeOpen(false); + if (RSVP?.response === "ACCEPTED") { + return "View QR Code"; + } + + return "Congrats! Click here to RSVP"; }; useEffect(() => { + // setRSVP({ + // admittedPro: false, + // reimbursementValue: 0.01, + // response: "PENDING", + // status: "ACCEPTED", + // userId: "0" + // }); + // setIsLoading(false); + if (!isAuthenticated()) { authenticate(pathname); return; @@ -86,35 +95,60 @@ const Profile: React.FC = () => { setRegistration(registrationFromAPI(registration)); Promise.all([getChallenge(), getRSVP()]).then( - ([challenge, RSVP]) => { + async ([challenge, RSVP]) => { setIsProApplicant(challenge.complete); setRSVP(RSVP); + if ( + RSVP.status === "ACCEPTED" && + RSVP.response === "ACCEPTED" + ) { + const qrCodeUrl = await getQRCode(); + setQRCodeURL(qrCodeUrl); + } setIsLoading(false); } ); }); - }, []); + }, [pathname, router]); return ( <> + {isLoading && } HackIllinois | Profile - - {RSVP && ( - setDetailsOpen(false)} - /> + {RSVP && RSVP.status !== "TBD" && RSVP.response !== "DECLINED" && ( + { + setModalOpen(false); + }} + ariaHideApp={false} + > +
+ {/* TODO: close button */} + +
+
)} - - {isLoading && }
{ className={styles.container} >

- {registration?.preferredName - ? `${registration?.preferredName.trim()}'s ` - : " "} - Application Status + {registration + ? `${ + registration?.preferredName + ? `${registration?.preferredName.trim()}'s ` + : " " + } + Application Status` + : "Loading..."}

@@ -196,24 +234,14 @@ const Profile: React.FC = () => {
{RSVP && - (RSVP.status === "ACCEPTED" && - RSVP.response === "ACCEPTED" ? ( + RSVP.status !== "TBD" && + RSVP.response !== "DECLINED" && ( setModalOpen(true)} medium /> - ) : ["ACCEPTED", "REJECTED"].includes( - RSVP.status - ) ? ( - - ) : ( - <> - ))} + )}
@@ -222,92 +250,57 @@ const Profile: React.FC = () => { ); }; -const QRModal: React.FC<{ - qrCodeOpen: boolean; - handleCloseQRCode: () => void; - qrCodeURL: string | null; -}> = ({ qrCodeOpen, handleCloseQRCode, qrCodeURL }) => { - const windowSizeHook = useWindowSize(); - +const QR: React.FC<{ qrUrl: string | null }> = ({ qrUrl }) => { return ( - -
-

Your QR Code

- {qrCodeURL && } - -
-
+ <> +

Your QR Code

+ {qrUrl && } + ); }; -const DetailsModal: React.FC<{ +type ModalContentProps = { + status: "ACCEPTED" | "REJECTED" | "WAITLISTED"; + response: "ACCEPTED" | "PENDING"; + isPro: boolean; isProApplicant: boolean; - rsvp: RSVPType; - detailsOpen: boolean; - handleCloseDetails: () => void; -}> = ({ isProApplicant, rsvp, detailsOpen, handleCloseDetails }) => { - const pages = { - user_rejected: UserRejected, - user_pro_accepted_to_pro: UserProAcceptedToPro, - user_pro_accepted_to_general: UserProAcceptedToGeneral, - user_general_accepted_to_general: UserGeneralAcceptedToGeneral - }; + qrUrl: string | null; + reimburse: number; +}; - const [displayedPage, setDisplayedPage] = useState< - keyof typeof pages | undefined - >(undefined); +const ModalContent: React.FC = ({ + status, + response, + isPro, + isProApplicant, + qrUrl, + reimburse +}) => { + switch (status) { + case "ACCEPTED": + if (response === "ACCEPTED") { + return ; + } - const handleLoadDisplayedPage = () => { - if (rsvp.response === "DECLINED") { - setDisplayedPage("user_rejected"); - return; - } - if (isProApplicant) { - if (rsvp.admittedPro) { - setDisplayedPage("user_pro_accepted_to_pro"); - } else { - setDisplayedPage("user_pro_accepted_to_general"); + if (isPro) { + return ; } - } else { - setDisplayedPage("user_general_accepted_to_general"); - } - }; - useEffect(() => { - handleLoadDisplayedPage(); - }, [rsvp?.response, rsvp?.status, rsvp?.admittedPro]); + if (isProApplicant) { + return ( + + ); + } - return ( - -
- {displayedPage && React.createElement(pages[displayedPage])} -
-
- ); + return ; + case "REJECTED": + return ; + case "WAITLISTED": + return ; + } }; export default Profile; diff --git a/components/Profile/RSVP/ModalViews/Accepted.tsx b/components/Profile/RSVP/ModalViews/Accepted.tsx index 21b60113..9a286cb0 100644 --- a/components/Profile/RSVP/ModalViews/Accepted.tsx +++ b/components/Profile/RSVP/ModalViews/Accepted.tsx @@ -1,20 +1,38 @@ import React from "react"; import styles from "./styles.module.scss"; -type Accepted = { - children: React.ReactNode; +type AcceptedType = "PRO" | "PRO_TO_GENERAL" | "GENERAL"; + +type AcceptedProps = { + acceptedType: AcceptedType; + reimburse: number; +}; + +export default function Accepted({ acceptedType, reimburse }: AcceptedProps) { + return ( + {}} + handleDecline={() => {}} + /> + ); +} + +type ChooseRSVPProps = { + acceptedType: AcceptedType; reimburse: number; handleConfirm: () => void; handleDecline: () => void; }; -export default function Accepted({ children, reimburse }: Accepted) { +export function ChooseRSVP({ reimburse, acceptedType }: ChooseRSVPProps) { return (
- {children} +

- If you would like to attend HackIllinois 2024, click Confirm + If you would like to attend HackIllinois 2025, click Confirm to finish the RSVP process. If you won't be attending please click Decline. This cannot be reversed.

@@ -31,24 +49,42 @@ export default function Accepted({ children, reimburse }: Accepted) { {/* */}
- {/*
- - -
*/}
); } + +type AcceptedVerbageProps = { + acceptedType: AcceptedType; +}; + +function AcceptedVerbage({ acceptedType }: AcceptedVerbageProps) { + switch (acceptedType) { + case "GENERAL": + return ( + <> + Congratulations! You've been accepted as a + + General Attendee + + ); + case "PRO_TO_GENERAL": + return ( + <> + + Unfortunately, we couldn't offer you a spot as a + HackKnight, but you've been accepted as a + + + General Attendee + + ); + case "PRO": + return ( + <> + Congratulations! You've been accepted as a + + HackOlympian + + ); + } +} diff --git a/components/Profile/RSVP/ModalViews/Rejected.tsx b/components/Profile/RSVP/ModalViews/Rejected.tsx index 2d4062a2..d5473bf8 100644 --- a/components/Profile/RSVP/ModalViews/Rejected.tsx +++ b/components/Profile/RSVP/ModalViews/Rejected.tsx @@ -1,10 +1,6 @@ import styles from "./styles.module.scss"; -type RejectedProps = { - handleCancel: () => void; -}; - -export default function Rejected({}: RejectedProps) { +export function Rejected() { return (
@@ -18,7 +14,25 @@ export default function Rejected({}: RejectedProps) { {" "} if you have any questions! - {/* */} +
+ ); +} + +// TODO: update this wording +export function Waitlisted() { + return ( +
+ + Unfortunately, we have deferred your application decision at + this time. + + + Email us at{" "} + + contact@hackillinois.org + {" "} + if you have any questions! +
); } diff --git a/components/RSVPContent/UserGeneralAcceptedToGeneral.tsx b/components/RSVPContent/UserGeneralAcceptedToGeneral.tsx deleted file mode 100644 index eddc4e4b..00000000 --- a/components/RSVPContent/UserGeneralAcceptedToGeneral.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const UserGeneralAcceptedToGeneral: React.FC = () => { - return

User pro accepted to general

; -}; - -export default UserGeneralAcceptedToGeneral; diff --git a/components/RSVPContent/UserProAcceptedToGeneral.tsx b/components/RSVPContent/UserProAcceptedToGeneral.tsx deleted file mode 100644 index 32e219d4..00000000 --- a/components/RSVPContent/UserProAcceptedToGeneral.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const UserProAcceptedToGeneral: React.FC = () => { - return

User pro accepted to general

; -}; - -export default UserProAcceptedToGeneral; diff --git a/components/RSVPContent/UserProAcceptedToPro.tsx b/components/RSVPContent/UserProAcceptedToPro.tsx deleted file mode 100644 index df80cd11..00000000 --- a/components/RSVPContent/UserProAcceptedToPro.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const UserProAcceptedToPro: React.FC = () => { - return

Pro user accepted to pro

; -}; - -export default UserProAcceptedToPro; diff --git a/components/RSVPContent/UserRejected.tsx b/components/RSVPContent/UserRejected.tsx deleted file mode 100644 index c3681de1..00000000 --- a/components/RSVPContent/UserRejected.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const UserRejected: React.FC = () => { - return

User rejected

; -}; - -export default UserRejected; diff --git a/util/api.ts b/util/api.ts index 88ebc972..ba7c65d3 100644 --- a/util/api.ts +++ b/util/api.ts @@ -59,8 +59,8 @@ export async function requestv2( } export async function getChallenge(): Promise { - const res = await requestv2("GET", "/registration/challenge/").catch(body => - handleError(body) + const res = await requestv2("GET", "/registration/challenge/").catch( + handleError ); return res; } @@ -106,7 +106,7 @@ export async function registerUpdate( registration: RegistrationType ): Promise> { const res = await requestv2("POST", `/registration`, registration).catch( - body => handleError(body) + handleError ); return res; } @@ -118,34 +118,32 @@ export async function registerSubmit( "POST", `/registration/submit`, registration - ).catch(body => handleError(body)); + ).catch(handleError); return res; } export async function getRegistrationStatus(): Promise<{ alive: boolean }> { - const res = await requestv2("GET", "/registration/status").catch(body => - handleError(body) + const res = await requestv2("GET", "/registration/status").catch( + handleError ); return res; } export async function getRSVP(): Promise { - const res = await requestv2("GET", "/admission/rsvp").catch(body => - handleError(body) - ); + const res = await requestv2("GET", "/admission/rsvp").catch(handleError); return res; } export async function RSVPDecideAccept() { - const res = await requestv2("PUT", "/admission/rsvp/accept").catch(body => - handleError(body) + const res = await requestv2("PUT", "/admission/rsvp/accept").catch( + handleError ); return res; } export async function RSVPDecideDecline() { - const res = await requestv2("PUT", "/admission/rsvp/decline").catch(body => - handleError(body) + const res = await requestv2("PUT", "/admission/rsvp/decline").catch( + handleError ); return res; } @@ -174,17 +172,15 @@ export async function unsubscribe(listName: string, emailAddress: string) { const res = await requestv2("DELETE", "/newsletter/subscribe/", { listName, emailAddress - }).catch(body => handleError(body)); + }).catch(handleError); return res; } export async function getQRCode(): Promise { - const res = await requestv2("GET", "/user/qr").catch(body => - handleError(body) - ); + const res = await requestv2("GET", "/user/qr").catch(handleError); return res.qrInfo; } export function setProfile(body: ProfileBodyType): Promise { - return requestv2("POST", "/profile", body); + return requestv2("POST", "/profile", body).catch(handleError); }