Fix jwt-token
This commit is contained in:
@@ -586,13 +586,21 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
|||||||
|
|
||||||
await api.put(`/devices/${device.id}`, updateData);
|
await api.put(`/devices/${device.id}`, updateData);
|
||||||
} else {
|
} 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 };
|
const createData = { ...formData };
|
||||||
|
|
||||||
|
// Convert empty strings to null for numeric fields, remove empty strings for optional string fields
|
||||||
Object.keys(createData).forEach(key => {
|
Object.keys(createData).forEach(key => {
|
||||||
if (createData[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);
|
await api.post('/devices', createData);
|
||||||
}
|
}
|
||||||
onSave();
|
onSave();
|
||||||
|
|||||||
Reference in New Issue
Block a user