bug fix for atemschutz

This commit is contained in:
Matthias Hochmeister
2026-03-01 18:11:00 +01:00
parent d074caa695
commit 5f0ed3c87e

View File

@@ -281,10 +281,19 @@ function Atemschutz() {
'leistungstest_datum', 'leistungstest_datum',
'leistungstest_gueltig_bis', '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) { for (const name of dateFieldNames) {
const input = dialogContentRef.current.querySelector(`input[name="${name}"]`) as HTMLInputElement | null; 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; return result;
}; };
@@ -303,7 +312,15 @@ function Atemschutz() {
const dates = readDatesFromDOM(); const dates = readDatesFromDOM();
// DEBUG: remove after confirming it works // DEBUG: remove after confirming it works
alert('DOM dates:\n' + JSON.stringify(dates, null, 2)); const debugInfo: Record<string, string> = {};
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) { if (editingId) {
const payload: UpdateAtemschutzPayload = { const payload: UpdateAtemschutzPayload = {