Merge pull request 'wisdom' (#48) from wisdom into main
Reviewed-on: #48
This commit is contained in:
@@ -31,6 +31,8 @@ const {
|
||||
} = require("../db/notification_wa.db");
|
||||
|
||||
const { ErrorHandler } = require("../helpers/error");
|
||||
const { deleteReminder } = require("./notifikasi-wa.service");
|
||||
const { getSparepartsByYearlyDb } = require("../db/sparepart.db");
|
||||
|
||||
class NotificationService {
|
||||
static async getAllNotification(param) {
|
||||
@@ -134,6 +136,16 @@ class NotificationService {
|
||||
|
||||
notification.activity_logs = notificationLogs;
|
||||
|
||||
notification.is_reminder = false;
|
||||
notification.spareparts_reminder = [];
|
||||
if (notification.message_error_issue) {
|
||||
const sparepartsReminder = await getSparepartsByYearlyDb(notification.error_code_id);
|
||||
|
||||
notification.spareparts_reminder = sparepartsReminder ?? [];
|
||||
notification.is_reminder = true;
|
||||
|
||||
}
|
||||
|
||||
return notification;
|
||||
} catch (error) {
|
||||
throw new ErrorHandler(error.statusCode, error.message);
|
||||
@@ -150,6 +162,8 @@ class NotificationService {
|
||||
|
||||
const notification = Array.isArray(dataExist) ? dataExist[0] : dataExist;
|
||||
|
||||
await deleteReminder(notification_error_id)
|
||||
|
||||
if (notification.is_read === true) {
|
||||
return { success: true, message: "Notification has already been read" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user