Fix jwt-token

This commit is contained in:
2025-08-28 08:28:02 +02:00
parent a68e664403
commit af8a5c5ffe
2 changed files with 27 additions and 13 deletions

View File

@@ -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) {