fix: update device
This commit is contained in:
@@ -28,9 +28,7 @@ class DeviceService {
|
||||
// Get device by code
|
||||
static async getDeviceByCode(code) {
|
||||
const device = await getDeviceByCodeDb(code);
|
||||
if (!device) {
|
||||
throw new ErrorHandler(404, 'Device not found');
|
||||
}
|
||||
if (!device) throw new ErrorHandler(404, 'Device not found');
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -40,7 +38,7 @@ class DeviceService {
|
||||
|
||||
data.created_by = userId;
|
||||
|
||||
// cek kode unik
|
||||
// Cek kode unik
|
||||
const existingDevice = await getDeviceByCodeDb(data.device_code);
|
||||
if (existingDevice) {
|
||||
throw new ErrorHandler(400, 'Device code already exists');
|
||||
@@ -61,14 +59,12 @@ class DeviceService {
|
||||
|
||||
data.updated_by = userId;
|
||||
|
||||
const updatedDevice = await updateDeviceDb(id, data);
|
||||
const updatedDevice = await updateDeviceDb(id, data);
|
||||
|
||||
|
||||
await updateDeviceDb(id, data);
|
||||
return {
|
||||
message: 'Device updated successfully',
|
||||
data: updatedDevice,
|
||||
};
|
||||
data: updatedDevice,
|
||||
};
|
||||
}
|
||||
|
||||
// Soft delete device
|
||||
|
||||
Reference in New Issue
Block a user