fix(api): add reminderMonthly & reminderCustom, notif too.
This commit is contained in:
@@ -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,
|
||||||
});
|
});
|
||||||
@@ -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 {
|
} else {
|
||||||
NotifAlert({
|
NotifAlert({
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
title: 'Gagal',
|
title: 'Gagal',
|
||||||
message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
|
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) {
|
} catch (error) {
|
||||||
console.error('Save Device Error:', error);
|
console.error('Save Device Error:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user