✨ Include the active period in the remaining time display
This commit is contained in:
@@ -8,8 +8,11 @@
|
||||
dayExpectedMs,
|
||||
entriesForRange,
|
||||
reopenWeek,
|
||||
runningDurationMs,
|
||||
runningEntry,
|
||||
todayKey,
|
||||
weekExpectedMs
|
||||
weekExpectedMs,
|
||||
workedMsForDay
|
||||
} from '$lib/app.svelte';
|
||||
import type { Doc } from '$lib/db.svelte';
|
||||
import type { ClosedDay } from '$lib/types';
|
||||
@@ -107,12 +110,13 @@
|
||||
|
||||
const DAY_NAMES = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
|
||||
let running = $derived(runningEntry());
|
||||
let runningMs = $derived(runningDurationMs());
|
||||
|
||||
function dayWorkedMs(dk: string): number {
|
||||
const cd = closedDaysMap[dk];
|
||||
if (cd) return cd.worked_ms;
|
||||
return weekEntries
|
||||
.filter((e) => e.day_key === dk && e.end_time != null)
|
||||
.reduce((sum, e) => sum + (e.end_time! - e.start_time), 0);
|
||||
return workedMsForDay(dk);
|
||||
}
|
||||
|
||||
const totalWorkedMs = $derived(
|
||||
@@ -162,6 +166,7 @@
|
||||
weekdayLabel={DAY_NAMES[i]}
|
||||
workedMs={dayWorkedMs(dk)}
|
||||
expectedMs={dayExpectedMs(dk)}
|
||||
runningMs={running?.day_key === dk ? runningMs : 0}
|
||||
kind={closedDaysMap[dk]?.kind ?? null}
|
||||
closed={!!closedDaysMap[dk]}
|
||||
isToday={dk === todayKey()}
|
||||
|
||||
Reference in New Issue
Block a user