import { useEffect, useState } from "react"; import { CircleCheck } from "lucide-react"; import { useTranslation } from "react-i18next"; import { Sheet, Typography, Chip, Button } from "@mui/joy"; export const SuccessPage = () => { const { t } = useTranslation(); const [orderId, setOrderId] = useState(null); const [tickets, setTickets] = useState(0); const [animate, setAnimate] = useState(false); const [seconds, setSeconds] = useState(30); useEffect(() => { const params = new URLSearchParams(window.location.search); setOrderId(params.get("id")); setTickets(parseInt(params.get("tickets") ?? "0", 10)); // Small delay so the CSS transition actually plays setTimeout(() => setAnimate(true), 100); document.body.classList.add("success-bg"); return () => { document.body.classList.remove("success-bg"); }; }, []); useEffect(() => { if (seconds === 0) { window.location.href = "/"; return; } const timer = setTimeout(() => setSeconds((s) => s - 1), 1000); return () => clearTimeout(timer); }, [seconds]); // Returns a style object that slides the element up + fades it in. // Each section gets a slightly later delay for a staggered entrance. const fadeUp = (delay: string): React.CSSProperties => ({ transition: `opacity 0.5s ease-in-out ${delay}, transform 0.5s ease-in-out ${delay}`, transform: animate ? "translateY(0)" : "translateY(20px)", opacity: animate ? 1 : 0, }); return (
{/* Green accent bar at the top */}
{/* Animated success icon */}
{/* Headline */}
{t("form-submitted-successfully")}
{/* Subtitle */}
{t("ticket-payment", { count: tickets })}
{/* Tickets chip */} {tickets > 0 && (
{tickets} {tickets === 1 ? t("ticket") : t("tickets")}
)} {/* Order ID chip */} {orderId && (
{t("entry-id")} #{orderId}
)} {/* Return button with countdown */}
{/* Thank-you note */}
{t("thank-you")}
); };