feat(admin): show paused sessions in live view; reset to live on logout

- Live cards freeze the worked timer at paused_at and show an amber
  "Gepauzeerd" badge plus a "Pauze H:MM:SS" total when paused.
- AuthContext.signOut resets the path to / so the next admin login lands
  on Live rather than the tab it logged out from.
This commit is contained in:
Bas van Rossem
2026-06-17 21:14:15 +02:00
parent a7c8925b3c
commit 0b0a6bd073
5 changed files with 52 additions and 2 deletions

View File

@@ -49,7 +49,13 @@ export default function Live() {
}
function LiveCard({ session, now }: { session: WorkSession; now: number }) {
const elapsed = formatTime((now - Date.parse(session.start_time)) / 1000);
// While paused the worked timer freezes at the pause moment; otherwise it counts to now.
// Worked = (base - start) - paused_seconds, where base is the pause moment when paused.
const base = session.paused_at ? Date.parse(session.paused_at) : now;
const worked = Math.max(
0,
Math.floor((base - Date.parse(session.start_time)) / 1000) - session.paused_seconds
);
return (
<article className="live-card">
<div className="live-card-head">
@@ -58,7 +64,11 @@ function LiveCard({ session, now }: { session: WorkSession; now: number }) {
</div>
<div className="live-activity">{session.activity_name ?? 'Onbekende handeling'}</div>
<div className="live-meta">{session.pair_count} zolen</div>
<div className="live-timer">{elapsed}</div>
<div className="live-timer">{formatTime(worked)}</div>
{session.paused_at && <span className="live-badge-paused">Gepauzeerd</span>}
{session.paused_seconds > 0 && (
<span className="live-paused-total">Pauze {formatTime(session.paused_seconds)}</span>
)}
</article>
);
}