mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 10:02:27 -04:00
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
20 lines
574 B
TypeScript
20 lines
574 B
TypeScript
import clsx from 'clsx'
|
|
import {useEffect, useState} from 'react'
|
|
import {getCountdownString} from 'web/lib/util/time'
|
|
|
|
export function Countdown(props: {endDate: Date; className?: string}) {
|
|
const {endDate, className} = props
|
|
|
|
const [countdown, setCountdown] = useState('')
|
|
useEffect(() => {
|
|
setCountdown(getCountdownString(endDate))
|
|
|
|
const intervalId = setInterval(() => {
|
|
setCountdown(getCountdownString(endDate))
|
|
}, 1000)
|
|
return () => clearInterval(intervalId)
|
|
}, [endDate])
|
|
|
|
return <span className={clsx(className)}>{countdown}</span>
|
|
}
|