fix: correct device name reference in notification message and adjust error handling in reminder saving logic

This commit is contained in:
2026-04-30 15:54:30 +07:00
parent 3c098d1c69
commit b811accc48

View File

@@ -393,6 +393,7 @@ class NotifikasiWaService {
const now = new Date(); const now = new Date();
const year = now.getFullYear(); const year = now.getFullYear();
const reminderAt = new Date(deviceReminder[0].reminder_at); const reminderAt = new Date(deviceReminder[0].reminder_at);
const deviceName = new Date(deviceReminder[0].device_name);
// 🔹 ambil bulan & jam dalam timezone server // 🔹 ambil bulan & jam dalam timezone server
const nowParts = new Intl.DateTimeFormat('en-US', { const nowParts = new Intl.DateTimeFormat('en-US', {
@@ -439,7 +440,7 @@ class NotifikasiWaService {
if (!checkNotifExist) { if (!checkNotifExist) {
const deviceNotification = await getSparepartsByYearlyDb(yearly); // const deviceNotification = await getSparepartsByYearlyDb(yearly);
const data = { const data = {
error_code_id: yearly ?? chanel.value, error_code_id: yearly ?? chanel.value,
@@ -455,6 +456,8 @@ class NotifikasiWaService {
await this.saveReminder({ await this.saveReminder({
notification_log: resultNotificationError.notification_error_id, notification_log: resultNotificationError.notification_error_id,
error_code_id: data['error_code_id'],
error_chanel: data['error_chanel'],
start_at: timeReminderString, start_at: timeReminderString,
interval: 1, interval: 1,
max: 3, max: 3,
@@ -483,7 +486,7 @@ class NotifikasiWaService {
const bodyMessage = const bodyMessage =
`Hai ${dataUser.contact_name || "-"},\n` + `Hai ${dataUser.contact_name || "-"},\n` +
`Diberitahukan bahwa terdapat sparepart pada device "${deviceNotification?.device_name ?? "-"}" ` + `Diberitahukan bahwa terdapat sparepart pada device "${deviceName ?? "-"}" ` +
`yang telah memasuki jadwal perawatan tahunan.\n` + `yang telah memasuki jadwal perawatan tahunan.\n` +
`\nSilakan segera lakukan pengecekan dan perawatan untuk memastikan kinerja tetap optimal.` + `\nSilakan segera lakukan pengecekan dan perawatan untuk memastikan kinerja tetap optimal.` +
`\nDetail sparepart dapat dilihat pada link berikut:\n${shortUrl}`; `\nDetail sparepart dapat dilihat pada link berikut:\n${shortUrl}`;