From af814022842f533e068ab3ae0f8cc8fa083bcbd8 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Tue, 23 Sep 2025 06:36:18 +0200 Subject: [PATCH] Fix jwt-token --- client/src/pages/Devices.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/src/pages/Devices.jsx b/client/src/pages/Devices.jsx index 0c1c191..d2357c5 100644 --- a/client/src/pages/Devices.jsx +++ b/client/src/pages/Devices.jsx @@ -586,13 +586,21 @@ const DeviceModal = ({ device, onClose, onSave }) => { await api.put(`/devices/${device.id}`, updateData); } else { - // Create new device - include all fields, convert empty strings to null + // Create new device - include all fields, handle empty values properly const createData = { ...formData }; + + // Convert empty strings to null for numeric fields, remove empty strings for optional string fields Object.keys(createData).forEach(key => { if (createData[key] === '') { - createData[key] = null; + if (['geo_lat', 'geo_lon', 'heartbeat_interval'].includes(key)) { + createData[key] = null; + } else if (['firmware_version', 'notes', 'location_description', 'name'].includes(key)) { + // Remove empty optional string fields instead of sending empty strings + delete createData[key]; + } } }); + await api.post('/devices', createData); } onSave();