diff --git a/web/src/components/PhoneMock.tsx b/web/src/components/PhoneMock.tsx index 9e625cf..cba4d3b 100644 --- a/web/src/components/PhoneMock.tsx +++ b/web/src/components/PhoneMock.tsx @@ -1,6 +1,29 @@ +import { useEffect, useState } from 'react'; import { CalendarClock, Wifi } from 'lucide-react'; import { StreakDots } from './StreakDots'; +const timeFmt = new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit' }); + +// zegar paska statusu = prawdziwa godzina „tu i teraz” +function useClock() { + const [now, setNow] = useState(() => new Date()); + useEffect(() => { + const id = setInterval(() => setNow(new Date()), 5000); + return () => clearInterval(id); + }, []); + return timeFmt.format(now); +} + +// odliczany w pętli czas przerwy między seriami +function useBreakCountdown(from = 45) { + const [secs, setSecs] = useState(from); + useEffect(() => { + const id = setInterval(() => setSecs((s) => (s > 0 ? s - 1 : from)), 1000); + return () => clearInterval(id); + }, [from]); + return `0:${String(secs).padStart(2, '0')}`; +} + function SignalIcon() { return (