diff --git a/frontend/src/app/(public)/invite/[slug]/page.tsx b/frontend/src/app/(public)/invite/[slug]/page.tsx index 5b0a1ed..e08a3b3 100644 --- a/frontend/src/app/(public)/invite/[slug]/page.tsx +++ b/frontend/src/app/(public)/invite/[slug]/page.tsx @@ -7,7 +7,7 @@ import { format, parseISO } from "date-fns"; import { Loader2 } from "lucide-react"; import { motion } from "framer-motion"; import { Button } from "@/components/ui/button"; -// import { RSVP } from "@/components/rsvp"; +import { RSVPModal } from "@/components/rsvp/rsvp-modal"; import { useParams } from "next/navigation"; import { getServerFileUrl } from "@/lib/utils"; @@ -21,6 +21,7 @@ const InvitationPage = () => { const [notFound, setNotFound] = useState(false); const [showRSVP, setShowRSVP] = useState(false); const { themes, isLoadingThemes } = useEventThemes(); + const guestId = "current-guest-id-placeholder"; // Fetch event data when slug is available useEffect(() => { @@ -398,7 +399,7 @@ const InvitationPage = () => { }} onClick={() => setShowRSVP(true)} > - PARTECIPO + PRESENZA )} @@ -456,6 +457,13 @@ const InvitationPage = () => { {/* RSVP Modal */} + + {/*{showRSVP && (*/} {/* void; +} + +export const RSVP: React.FC = ({ + eventId, + guestId, + onRSVPSuccess, +}) => { + const { createRsvp } = useRSVPs(); + + const [status, setStatus] = useState(RsvpStatus.ATTENDING); + const [number_of_guests, setNumberOfGuests] = useState(1); + const [response_message, setResponseMessage] = useState(""); + const [dietary_requirements, setDietaryRequirements] = useState(""); + + const submitRsvp = async (e: React.FormEvent) => { + e.preventDefault(); + + await createRsvp({ + event_id: eventId, + guest_id: guestId, + status, + number_of_guests, + response_message, + dietary_requirements, + }); + + if (onRSVPSuccess) { + onRSVPSuccess(); + } + }; + + return ( +
+

+ RSVP to this Event +

+ +
+ + +
+ +
+ + + setNumberOfGuests(Math.max(1, Number(e.target.value))) + } + /> +
+ +
+ +