import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; const DISCOUNT_CODE = "ILOVEB2V"; const DISCOUNT_PERCENT = "20%"; const DURATION_MS = 4 * 24 * 60 * 60 * 1000; // 4 days cycle const START_TIME = new Date("2026-03-16T00:00:00Z").getTime(); // global start time function useDiscountCountdown() { const [now, setNow] = useState(Date.now()); useEffect(() => { const id = setInterval(() => setNow(Date.now()), 1000); return () => clearInterval(id); }, []); const elapsed = (now - START_TIME) % DURATION_MS; const remaining = DURATION_MS - elapsed; const totalSeconds = Math.floor(remaining / 1000); const days = Math.floor(totalSeconds / (24 * 3600)); const hours = Math.floor((totalSeconds % (24 * 3600)) / 3600); const minutes = Math.floor((totalSeconds % 3600) / 60); const seconds = totalSeconds % 60; return { days, hours, minutes, seconds }; } interface Props { className?: string; } export default function DiscountCodeBadge({ className = "" }: Props) { const [copied, setCopied] = useState(false); const countdown = useDiscountCountdown(); const handleCopy = () => { navigator.clipboard?.writeText(DISCOUNT_CODE).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1500); }); }; const pad = (n: number) => n.toString().padStart(2, "0"); return (