From ede8e8018192e90bde936e82339fd183fdf08e1a Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 6 Mar 2025 10:46:53 +0700 Subject: [PATCH] feat: add notification route and functions to delete and mark notifications as read --- src/router/routes.ts | 6 +++++- src/stores/notification/index.ts | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/router/routes.ts b/src/router/routes.ts index 6d752495..2f7405d1 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -135,6 +135,11 @@ const routes: RouteRecordRaw[] = [ name: 'dashBoard', component: () => import('pages/15_dash-board/MainPage.vue'), }, + { + path: '/notification', + name: 'Notification', + component: () => import('pages/00_notification/MainPage.vue'), + }, ], }, @@ -208,7 +213,6 @@ const routes: RouteRecordRaw[] = [ name: 'DebitNoteView', component: () => import('pages/12_debit-note/FormPage.vue'), }, - { path: '/debit-note/document-view', name: 'DebitNoteDocumentView', diff --git a/src/stores/notification/index.ts b/src/stores/notification/index.ts index 4f3d4cfe..cfeb63ba 100644 --- a/src/stores/notification/index.ts +++ b/src/stores/notification/index.ts @@ -54,6 +54,26 @@ export const useNotification = defineStore('noti-store', () => { return res.data; } + async function deleteMultiNotification(notificationId: string[]) { + const res = await api.delete( + '/notification', + { + data: notificationId, + }, + ); + if (res.status >= 400) return null; + return true; + } + + async function markReadNotification(notificationId: string[]) { + const res = await api.post( + '/notification/mark-read', + { id: notificationId }, + ); + if (res.status >= 400) return null; + return true; + } + return { ...state, @@ -61,5 +81,7 @@ export const useNotification = defineStore('noti-store', () => { getNotificationList, updateNotification, deleteNotification, + deleteMultiNotification, + markReadNotification, }; });