Fix jwt-token

This commit is contained in:
2025-09-23 06:36:18 +02:00
parent f779b799c0
commit af81402284

View File

@@ -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();