add: reminder whatsapp sparepart monthly
This commit is contained in:
@@ -31,7 +31,7 @@ const {
|
||||
} = require("../db/notification_wa.db");
|
||||
|
||||
const { ErrorHandler } = require("../helpers/error");
|
||||
const { getSparepartsByYearlyDb } = require("../db/sparepart.db");
|
||||
const { getSparepartsByYearlyDb, getSparepartsByMonthlyDb } = require("../db/sparepart.db");
|
||||
|
||||
const notifikasiWaService = require("./notifikasi-wa.service");
|
||||
|
||||
@@ -140,11 +140,18 @@ class NotificationService {
|
||||
notification.is_reminder = false;
|
||||
notification.spareparts_reminder = [];
|
||||
if (notification.message_error_issue) {
|
||||
const sparepartsReminder = await getSparepartsByYearlyDb(notification.error_code_id);
|
||||
|
||||
notification.spareparts_reminder = sparepartsReminder ?? [];
|
||||
const [sparepartsYearly, sparepartsMonthly] = await Promise.all([
|
||||
getSparepartsByYearlyDb(notification.error_code_id),
|
||||
getSparepartsByMonthlyDb(notification.error_code_id)
|
||||
]);
|
||||
|
||||
notification.spareparts_reminder = [
|
||||
...(sparepartsYearly ?? []),
|
||||
...(sparepartsMonthly ?? [])
|
||||
];
|
||||
|
||||
notification.is_reminder = true;
|
||||
|
||||
}
|
||||
|
||||
return notification;
|
||||
@@ -172,7 +179,7 @@ class NotificationService {
|
||||
if (!notification.is_read) {
|
||||
const updateStatus = await updateNotificationErrorDb(
|
||||
notification_error_id,
|
||||
{ is_read: true}
|
||||
{ is_read: true }
|
||||
);
|
||||
|
||||
if (!updateStatus) {
|
||||
|
||||
Reference in New Issue
Block a user