fix(api): add reminderMonthly & reminderCustom, notif too.
This commit is contained in:
@@ -99,8 +99,8 @@ const DetailDevice = (props) => {
|
||||
: await createDevice(payload);
|
||||
|
||||
const response2 = formData.period !== 'custom'
|
||||
? await updateDevice(formData.device_id, { reminder_at_monthly: formData.reminder_at_monthly,})
|
||||
: await updateDevice(formData.device_id, {
|
||||
? await reminderMonthly(formData.device_id, { reminder_at_monthly: formData.reminder_at_monthly,})
|
||||
: await reminderCustom(formData.device_id, {
|
||||
start_date: formData.start_date,
|
||||
end_date: formData.end_date,
|
||||
});
|
||||
@@ -118,17 +118,10 @@ const DetailDevice = (props) => {
|
||||
});
|
||||
|
||||
props.setActionMode('list');
|
||||
} else {
|
||||
NotifAlert({
|
||||
icon: 'error',
|
||||
title: 'Gagal',
|
||||
message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
|
||||
});
|
||||
}
|
||||
|
||||
// Check if response Reminder At(Monthly) or Period are successful
|
||||
setTimeout(() => {
|
||||
const tipe = formData.period !== 'custom' ? 'Reminder At(Monthly)' : 'Period';
|
||||
if (response2 && (response2.statusCode === 200 || response2.statusCode === 201)) {
|
||||
if (response2?.success) {
|
||||
NotifSmall({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
@@ -143,6 +136,15 @@ const DetailDevice = (props) => {
|
||||
`Terjadi kesalahan saat menyimpan ${tipe}`,
|
||||
});
|
||||
}
|
||||
}, 4000); // 2 detik
|
||||
|
||||
} else {
|
||||
NotifAlert({
|
||||
icon: 'error',
|
||||
title: 'Gagal',
|
||||
message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Save Device Error:', error);
|
||||
|
||||
Reference in New Issue
Block a user