"use client"; import { useEffect, useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { HeartFilledIcon } from "./icons"; import { fontMono, fontCursive } from "@/config/fonts"; interface TimeLeft { days: number; hours: number; minutes: number; seconds: number; } type TimerPhase = | "BEFORE_WEDDING" | "WEDDING_DAY" | "BEFORE_RECEPTION" | "RECEPTION_DAY" | "POST_EVENT"; export default function CountdownTimer() { const [timeLeft, setTimeLeft] = useState(null); const [phase, setPhase] = useState("BEFORE_WEDDING"); useEffect(() => { const weddingStart = new Date("2026-01-23T18:00:00").getTime(); const weddingEnd = new Date("2026-01-24T06:00:00").getTime(); const receptionStart = new Date("2026-01-25T18:00:00").getTime(); const receptionEnd = new Date("2026-01-26T06:00:00").getTime(); const calculateTimeLeft = () => { const now = new Date().getTime(); let currentPhase: TimerPhase = "BEFORE_WEDDING"; let targetDate = weddingStart; if (now < weddingStart) { currentPhase = "BEFORE_WEDDING"; targetDate = weddingStart; } else if (now >= weddingStart && now < weddingEnd) { currentPhase = "WEDDING_DAY"; } else if (now >= weddingEnd && now < receptionStart) { currentPhase = "BEFORE_RECEPTION"; targetDate = receptionStart; } else if (now >= receptionStart && now < receptionEnd) { currentPhase = "RECEPTION_DAY"; } else { currentPhase = "POST_EVENT"; } setPhase(currentPhase); if ( currentPhase === "BEFORE_WEDDING" || currentPhase === "BEFORE_RECEPTION" ) { const difference = targetDate - now; setTimeLeft({ days: Math.floor(difference / (1000 * 60 * 60 * 24)), hours: Math.floor((difference / (1000 * 60 * 60)) % 24), minutes: Math.floor((difference / 1000 / 60) % 60), seconds: Math.floor((difference / 1000) % 60), }); } else { setTimeLeft(null); } }; calculateTimeLeft(); const timer = setInterval(calculateTimeLeft, 1000); return () => clearInterval(timer); }, []); const TimeUnit = ({ value, label }: { value: number; label: string }) => (
{String(value).padStart(2, "0")}
{label}
); return (
{(phase === "BEFORE_WEDDING" || phase === "BEFORE_RECEPTION") && timeLeft ? (
:
:
:
) : (

{phase === "WEDDING_DAY" && "Today is our Wedding Day!"} {phase === "RECEPTION_DAY" && "Today is our Reception!"} {phase === "POST_EVENT" && "Just Married!"}

)}

{" "} {phase === "BEFORE_WEDDING" && 'Until we say "I Do"'} {phase === "BEFORE_RECEPTION" && "Until the Grand Reception"} {phase === "POST_EVENT" && "Happily Ever After"} {(phase === "WEDDING_DAY" || phase === "RECEPTION_DAY") && "The Celebration Continues..."}

); }