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);
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,
});
@@ -117,32 +117,34 @@ 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 {
NotifAlert({
icon: 'error',
title: 'Gagal',
message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
});
}
// 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) {
console.error('Save Device Error:', error);