{t.uptime.title}
+{t.uptime.subtitle}
+diff --git a/src/components/UpdateTimer.jsx b/src/components/UpdateTimer.jsx new file mode 100644 index 0000000..31d8727 --- /dev/null +++ b/src/components/UpdateTimer.jsx @@ -0,0 +1,43 @@ +import React, { useState, useEffect } from 'react'; + +const REFRESH_INTERVAL = 300; // seconds + +export default function UpdateTimer({ onRefresh }) { + const [secondsLeft, setSecondsLeft] = useState(REFRESH_INTERVAL); + + useEffect(() => { + const interval = setInterval(() => { + setSecondsLeft((prev) => { + if (prev > 1) { + return prev - 1; + } else { + if (typeof onRefresh === 'function') onRefresh(); + return REFRESH_INTERVAL; + } + }); + }, 1000); + return () => clearInterval(interval); + }, [onRefresh]); + + const percent = (secondsLeft / REFRESH_INTERVAL) * 100; + const coverPercent = 100 - percent; + + return ( +
{t.uptime.subtitle}
+