fix(api): add reminderMonthly & reminderCustom, notif too.

This commit is contained in:
2026-07-09 15:54:05 +07:00
parent ec067bf4e4
commit 50636f616b

View File

@@ -99,8 +99,8 @@ const DetailDevice = (props) => {
: await createDevice(payload); : await createDevice(payload);
const response2 = formData.period !== 'custom' const response2 = formData.period !== 'custom'
? await updateDevice(formData.device_id, { reminder_at_monthly: formData.reminder_at_monthly,}) ? await reminderMonthly(formData.device_id, { reminder_at_monthly: formData.reminder_at_monthly,})
: await updateDevice(formData.device_id, { : await reminderCustom(formData.device_id, {
start_date: formData.start_date, start_date: formData.start_date,
end_date: formData.end_date, end_date: formData.end_date,
}); });
@@ -118,6 +118,26 @@ const DetailDevice = (props) => {
}); });
props.setActionMode('list'); props.setActionMode('list');
setTimeout(() => {
const tipe = formData.period !== 'custom' ? 'Reminder At(Monthly)' : 'Period';
if (response2?.success) {
NotifSmall({
icon: 'success',
title: 'Berhasil',
message: `${tipe} berhasil disimpan`,
});
} else {
NotifSmall({
icon: 'error',
title: 'Gagal',
message:
response?.message ||
`Terjadi kesalahan saat menyimpan ${tipe}`,
});
}
}, 4000); // 2 detik
} else { } else {
NotifAlert({ NotifAlert({
icon: 'error', icon: 'error',
@@ -126,24 +146,6 @@ const DetailDevice = (props) => {
}); });
} }
// Check if response Reminder At(Monthly) or Period are successful
const tipe = formData.period !== 'custom' ? 'Reminder At(Monthly)' : 'Period';
if (response2 && (response2.statusCode === 200 || response2.statusCode === 201)) {
NotifSmall({
icon: 'success',
title: 'Berhasil',
message: `${tipe} berhasil disimpan`,
});
} else {
NotifSmall({
icon: 'error',
title: 'Gagal',
message:
response?.message ||
`Terjadi kesalahan saat menyimpan ${tipe}`,
});
}
} catch (error) { } catch (error) {
console.error('Save Device Error:', error); console.error('Save Device Error:', error);
NotifAlert({ NotifAlert({