diff --git a/frontend/src/Components/Pages/GroupImagesPage.js b/frontend/src/Components/Pages/GroupImagesPage.js index 08a9af8..493ee10 100644 --- a/frontend/src/Components/Pages/GroupImagesPage.js +++ b/frontend/src/Components/Pages/GroupImagesPage.js @@ -105,37 +105,38 @@ const GroupImagesPage = () => { setMetadata(prev => ({ ...prev, [field]: value })); }; - const handleSave = async () => { - if (!group) return; - setSaving(true); - try { - const payload = { - title: group.title, - description: group.description, - year: group.year, - name: group.name - }; + const handleSave = async () => { + if (!group) return; + setSaving(true); + try { + // Use metadata state (controlled by DescriptionInput) as source of truth + const payload = { + title: metadata.title, + description: metadata.description, + year: metadata.year, + name: metadata.name + }; - const res = await fetch(`/groups/${groupId}`, { - method: 'PATCH', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(payload) - }); + const res = await fetch(`/groups/${groupId}`, { + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(payload) + }); - if (!res.ok) { - const body = await res.json().catch(() => ({})); - throw new Error(body.message || 'Speichern fehlgeschlagen'); - } + if (!res.ok) { + const body = await res.json().catch(() => ({})); + throw new Error(body.message || 'Speichern fehlgeschlagen'); + } - Swal.fire({ icon: 'success', title: 'Gruppe erfolgreich aktualisiert', timer: 1500, showConfirmButton: false }); - history.push('/moderation'); - } catch (e) { - console.error(e); - Swal.fire({ icon: 'error', title: 'Fehler beim Speichern', text: e.message }); - } finally { - setSaving(false); - } - }; + Swal.fire({ icon: 'success', title: 'Gruppe erfolgreich aktualisiert', timer: 1500, showConfirmButton: false }); + history.push('/moderation'); + } catch (e) { + console.error(e); + Swal.fire({ icon: 'error', title: 'Fehler beim Speichern', text: e.message }); + } finally { + setSaving(false); + } + }; const handleDeleteImage = async (imageId) => { if (!window.confirm('Bild wirklich löschen?')) return;