diff --git a/src/pages/master/device/component/DetailDevice.jsx b/src/pages/master/device/component/DetailDevice.jsx index 2a2b95b..4c083aa 100644 --- a/src/pages/master/device/component/DetailDevice.jsx +++ b/src/pages/master/device/component/DetailDevice.jsx @@ -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);