Add 'apps/mobile/' from commit '5fa30f365f21531094cd4d2045042bb4f1370ac3'

git-subtree-dir: apps/mobile
git-subtree-mainline: 86f8987dff
git-subtree-split: 5fa30f365f
This commit is contained in:
2026-08-16 21:42:59 -04:00
222 changed files with 23436 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { useEffect, useState } from "react";
/** Live elapsed seconds since `startedAt`, ticking every second. */
export function useRunningElapsed(startedAt?: string | Date | null) {
const [elapsed, setElapsed] = useState(0);
useEffect(() => {
if (!startedAt) {
setElapsed(0);
return;
}
const startMs = new Date(startedAt).getTime();
if (Number.isNaN(startMs)) {
setElapsed(0);
return;
}
const tick = () => {
setElapsed(Math.max(0, Math.floor((Date.now() - startMs) / 1000)));
};
tick();
const id = setInterval(tick, 1000);
return () => clearInterval(id);
}, [startedAt]);
return elapsed;
}