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:
@@ -23,6 +23,8 @@ function makeSession(over: Partial<WorkSession>): WorkSession {
|
||||
start_time: new Date(Date.now() - 65_000).toISOString(),
|
||||
end_time: null,
|
||||
duration_seconds: null,
|
||||
paused_seconds: 0,
|
||||
paused_at: null,
|
||||
status: 'active',
|
||||
source: 'app',
|
||||
notes: null,
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user