fix: handle object-format select_options from Paperless for Freigabe field
Build and Push Multi-Platform Images / build-and-push (push) Successful in 36s

Paperless may return extra_data.select_options as an array of objects
{id, label} instead of plain strings. This caused React error #31
when Ant Design tried to render an object as a child in the Select and
Table components.

- Backend: coerce option items to {id: string, label: string} regardless
  of whether Paperless returns strings or objects
- Frontend: normalize cf.value to a plain string before rendering or
  storing in state, guarding against object-typed values

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 07:01:39 +02:00
parent a0d67c7d1b
commit d5bc1bcee0
2 changed files with 24 additions and 9 deletions
+11 -6
View File
@@ -67,19 +67,24 @@ export default function FreigabePage() {
return correspondents.find((c) => c.id === id)?.name ?? String(id);
};
const toCfString = (value: any): string | null => {
if (value === null || value === undefined || value === '') return null;
if (typeof value === 'object') return String(value?.id ?? value?.value ?? value?.label ?? '') || null;
return String(value);
};
const getFreigabeValue = (doc: FreigabeDocument) => {
const cf = doc.custom_fields?.find((f) => f.field === FREIGABE_FIELD_ID);
if (!cf || cf.value === null || cf.value === '' || cf.value === undefined) {
return <Tag color="warning">Nicht gesetzt</Tag>;
}
const opt = freigabeOptions.find((o) => String(o.id) === String(cf.value));
return <Tag color="success">{opt?.label ?? String(cf.value)}</Tag>;
const cfStr = toCfString(cf?.value);
if (!cfStr) return <Tag color="warning">Nicht gesetzt</Tag>;
const opt = freigabeOptions.find((o) => o.id === cfStr);
return <Tag color="success">{opt?.label ?? cfStr}</Tag>;
};
const openModal = (doc: FreigabeDocument) => {
const cf = doc.custom_fields?.find((f) => f.field === FREIGABE_FIELD_ID);
setSelectedDoc(doc);
setSelectedValue(cf?.value ?? null);
setSelectedValue(toCfString(cf?.value));
setModalOpen(true);
};