bug fix for atemschutz
This commit is contained in:
@@ -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<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) {
|
||||
const payload: UpdateAtemschutzPayload = {
|
||||
|
||||
Reference in New Issue
Block a user