import { Code, Flex, Heading, Link, Text } from "@radix-ui/themes"; import { useEffect, useState, type ReactNode } from "react"; import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps"; import { InlineSkeleton } from "./InlineSkeleton"; const TIME = 1764898200 * 1000; export function Giveaway({ skeleton }: MaybeSkeletonComponentProps) { const [timeLeft, setTimeLeft] = useState(TIME - Date.now()); useEffect(() => { const interval = setInterval(() => { setTimeLeft(TIME - Date.now()); }, 1000); return () => { clearInterval(interval); }; }, []); let string: ReactNode; if (timeLeft > 0) { const hours = Math.floor(timeLeft / (1000 * 60 * 60)); const minutes = Math.floor((timeLeft / (1000 * 60)) % 60) .toString() .padStart(2, "0"); const seconds = Math.floor((timeLeft / 1000) % 60) .toString() .padStart(2, "0"); string = ( <> in{" "} {hours}h {minutes}m {seconds}s ); } else { string = "has ended. Come again later!"; } return ( Music Box giveaway {!skeleton && string}{" "} {skeleton && } Join the BlitzKit Discord server event ); }