From 5f0ed3c87e70d6b418a3adb79134ff86037ed4f4 Mon Sep 17 00:00:00 2001 From: Matthias Hochmeister Date: Sun, 1 Mar 2026 18:11:00 +0100 Subject: [PATCH] bug fix for atemschutz --- frontend/src/pages/Atemschutz.tsx | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Atemschutz.tsx b/frontend/src/pages/Atemschutz.tsx index 1c19199..dfe273b 100644 --- a/frontend/src/pages/Atemschutz.tsx +++ b/frontend/src/pages/Atemschutz.tsx @@ -281,10 +281,19 @@ function Atemschutz() { 'leistungstest_datum', 'leistungstest_gueltig_bis', ]; - if (!dialogContentRef.current) return result; + if (!dialogContentRef.current) { + // Fallback: read from React state + for (const name of dateFieldNames) { + result[name] = normalizeDate((form as any)[name] || undefined); + } + return result; + } for (const name of dateFieldNames) { const input = dialogContentRef.current.querySelector(`input[name="${name}"]`) as HTMLInputElement | null; - result[name] = normalizeDate(input?.value || undefined); + const domVal = input?.value || ''; + const stateVal = (form as any)[name] || ''; + // Use DOM value if available, otherwise fall back to React state + result[name] = normalizeDate(domVal || stateVal || undefined); } return result; }; @@ -303,7 +312,15 @@ function Atemschutz() { const dates = readDatesFromDOM(); // DEBUG: remove after confirming it works - alert('DOM dates:\n' + JSON.stringify(dates, null, 2)); + const debugInfo: Record = {}; + const ref = dialogContentRef.current; + if (ref) { + for (const n of ['lehrgang_datum', 'leistungstest_gueltig_bis']) { + const el = ref.querySelector(`input[name="${n}"]`) as HTMLInputElement | null; + debugInfo[n] = el ? `found, value="${el.value}"` : 'NOT FOUND in DOM'; + } + } + alert('DOM dates:\n' + JSON.stringify(dates, null, 2) + '\n\nDebug:\n' + JSON.stringify(debugInfo, null, 2)); if (editingId) { const payload: UpdateAtemschutzPayload = {