import { useMemo, forwardRef } from 'react'; import { Timer } from './timer'; import { Notice } from './notice'; import { useCountdownTimers } from '@/stores/countdown-timers'; import styles from './timers.module.css'; interface TimersProps { enableAnimations: (enabled: boolean) => void; } export const Timers = forwardRef(function Timers( { enableAnimations }: TimersProps, ref: React.ForwardedRef, ) { const timers = useCountdownTimers(state => state.timers); const spent = useCountdownTimers(state => state.spent()); const total = useCountdownTimers(state => state.total()); const spentMinutes = useMemo(() => Math.floor(spent / 60), [spent]); const totalMinutes = useMemo(() => Math.floor(total / 60), [total]); return (
{timers.length > 0 ? (

Timers

{totalMinutes > 0 && (

{spentMinutes} / {totalMinutes} Minute {totalMinutes !== 1 && 's'}

)}
{timers.map(timer => ( ))}
) : null}
); });