feat(data): dedupe history by (date, employeeId)

This commit is contained in:
ferdi2go committed 2026-04-28 10:21:18 +00:00
1 parent 3d314e84fd
commit 23683102bc
3 files changed
+51 -4

No files matched your search

+3 -3
View File
@@ -61,11 +61,11 @@ export function toggleClosure(state, isoDate) {
if (idx >= 0) arr.splice(idx, 1); else arr.push(isoDate);
}
// Adds entries to history, replacing any existing entries for the same dates
// Adds entries to history, replacing any existing entries with the same (date, employeeId)
export function addHistoryEntries(state, entries) {
if (!entries?.length) return;
const dates = new Set(entries.map(e => e.date));
state.history = state.history.filter(h => !dates.has(h.date));
const keys = new Set(entries.map(e => e.date + '|' + e.employeeId));
state.history = state.history.filter(h => !keys.has(h.date + '|' + h.employeeId));
state.history.push(...entries);
state.history.sort((a, b) => a.date.localeCompare(b.date));
}