fix(robustness): parseInt radix, minGapDays null-guard, log silent catches (#14)

- parseInt(month/year) now passes radix 10 consistently.
- minGap eligibility guards null/undefined (c.minGapDays != null && > 0).
- The corrupt-localStorage load and the createEmployee catch now console.warn
  instead of swallowing the error silently.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ferdi2goandClaude Opus 4.8 committed 2026-06-03 13:05:34 +00:00
1 parent fd9870871b
commit 7ab2911c2f
4 files changed
+8 -6

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@ function isEligible(employee, isoDate, monthAssignments, allHistory) {
if (count >= c.maxPerMonth) return false;
}
if (c.minGapDays > 0) {
if (c.minGapDays != null && c.minGapDays > 0) {
// Latest prior assignment date for this employee — single pass, no sort/alloc
let lastDate = null;
const isLater = a => a.employeeId === employee.id && a.date < isoDate &&
+3 -2
View File
@@ -26,8 +26,9 @@ try {
state.settings = { moderatorsPerDay: parsed.settings.moderatorsPerDay };
}
}
} catch {
// Corrupt storage — start fresh
} catch (e) {
// Corrupt storage — start fresh, but leave a breadcrumb for debugging
console.warn('Gespeicherter Zustand konnte nicht gelesen werden, starte leer:', e);
}
// Persist immediately. Used by the debounced saveState and the flush handlers.
+2 -2
View File
@@ -99,13 +99,13 @@ export function renderCalendar() {
renderGrid(wrapper, exportBtn);
monthSel.addEventListener('change', () => {
currentMonth = parseInt(monthSel.value);
currentMonth = parseInt(monthSel.value, 10);
loadPlanFromHistory();
renderGrid(wrapper, exportBtn);
});
yearSel.addEventListener('change', () => {
currentYear = parseInt(yearSel.value);
currentYear = parseInt(yearSel.value, 10);
loadPlanFromHistory();
renderGrid(wrapper, exportBtn);
});
+2 -1
View File
@@ -54,7 +54,8 @@ export function renderEmployees() {
if (!name) return;
try {
state.employees.push(createEmployee(name));
} catch {
} catch (err) {
console.warn('Mitarbeiter konnte nicht angelegt werden:', err);
return;
}
nameInput.value = '';