Fix jwt-token
This commit is contained in:
@@ -555,16 +555,30 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
||||
|
||||
try {
|
||||
if (device) {
|
||||
// Update existing device - exclude read-only fields
|
||||
// Update existing device - exclude read-only fields and filter out empty strings
|
||||
const updateData = {
|
||||
name: formData.name,
|
||||
location_description: formData.location_description,
|
||||
notes: formData.notes
|
||||
location_description: formData.location_description || null,
|
||||
notes: formData.notes || null
|
||||
};
|
||||
|
||||
// Remove null values to avoid sending unnecessary data
|
||||
Object.keys(updateData).forEach(key => {
|
||||
if (updateData[key] === null || updateData[key] === '') {
|
||||
delete updateData[key];
|
||||
}
|
||||
});
|
||||
|
||||
await api.put(`/devices/${device.id}`, updateData);
|
||||
} else {
|
||||
// Create new device - include all fields
|
||||
await api.post('/devices', formData);
|
||||
// Create new device - include all fields, convert empty strings to null
|
||||
const createData = { ...formData };
|
||||
Object.keys(createData).forEach(key => {
|
||||
if (createData[key] === '') {
|
||||
createData[key] = null;
|
||||
}
|
||||
});
|
||||
await api.post('/devices', createData);
|
||||
}
|
||||
onSave();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user