import { useState, useEffect } from "react"; import { motion } from "framer-motion"; import { Button } from "@/components/ui/button"; import { EVENT_INFO } from "@/data/event-data"; import heroBg from "@/assets/hero-bg.jpg"; /** Calcula diferencia entre ahora y la fecha del evento */ const getTimeLeft = (target: string) => { const diff = new Date(target).getTime() - Date.now(); if (diff <= 0) return { days: 0, hours: 0, minutes: 0, seconds: 0 }; return { days: Math.floor(diff / (1000 * 60 * 60 * 24)), hours: Math.floor((diff / (1000 * 60 * 60)) % 24), minutes: Math.floor((diff / (1000 * 60)) % 60), seconds: Math.floor((diff / 1000) % 60), }; }; const HeroSection = () => { const [timeLeft, setTimeLeft] = useState(getTimeLeft(EVENT_INFO.date)); useEffect(() => { const timer = setInterval(() => { setTimeLeft(getTimeLeft(EVENT_INFO.date)); }, 1000); return () => clearInterval(timer); }, []); const countdownItems = [ { value: timeLeft.days, label: "Días" }, { value: timeLeft.hours, label: "Horas" }, { value: timeLeft.minutes, label: "Min" }, { value: timeLeft.seconds, label: "Seg" }, ]; return (
{/* Background image */}
{/* Overlay */}
{EVENT_INFO.dateDisplay} · {EVENT_INFO.city} {EVENT_INFO.name} {EVENT_INFO.subtitle} {/* Countdown */} {countdownItems.map((item) => (
{String(item.value).padStart(2, "0")}

{item.label}

))}
); }; export default HeroSection;