'use client' import { useState, useEffect } from 'react' interface CountdownProps { targetDate: Date label?: string } export function Countdown({ targetDate, label = "EARLY BIRD CLOSES IN" }: CountdownProps) { const [timeLeft, setTimeLeft] = useState({ days: 0, hours: 0, minutes: 0, seconds: 0, }) useEffect(() => { const calculateTimeLeft = () => { const difference = targetDate.getTime() - new Date().getTime() if (difference > 0) { 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), }) } } calculateTimeLeft() const timer = setInterval(calculateTimeLeft, 1000) return () => clearInterval(timer) }, [targetDate]) const timeBlocks = [ { value: timeLeft.days, label: 'DAYS' }, { value: timeLeft.hours, label: 'HRS' }, { value: timeLeft.minutes, label: 'MIN' }, { value: timeLeft.seconds, label: 'SEC' }, ] return (

{label}

{timeBlocks.map((block, index) => (
{String(block.value).padStart(2, '0')} {block.label}
))}
) }