feat: auto-persist state to localStorage on every change

This commit is contained in:
Ferdinand
2026-04-08 14:17:24 +02:00
parent 6ecf3e4409
commit dca82fe381
4 changed files with 47 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { state } from './app.js';
import { state, saveState } from './app.js';
import { loadFromJSON, saveToJSON, removeHistoryEntry } from './data.js';
import { downloadBlob } from './excel.js';
@@ -79,6 +79,7 @@ export function renderDataTab() {
state.employees = loaded.employees;
state.calendar = loaded.calendar;
state.history = loaded.history;
saveState();
alert('Daten erfolgreich geladen.');
renderDataTab();
} catch (err) {
@@ -136,6 +137,7 @@ function renderHistoryTable() {
delBtn.style.cssText = 'font-size:11px;padding:2px 6px';
delBtn.addEventListener('click', () => {
removeHistoryEntry(state, h.date);
saveState();
renderHistoryTable();
});
actionTd.appendChild(delBtn);