diff --git a/src/i18n/eng.ts b/src/i18n/eng.ts index c58c3940..da76eba9 100644 --- a/src/i18n/eng.ts +++ b/src/i18n/eng.ts @@ -241,6 +241,16 @@ export default { }, }, + noti: { + title: 'Notification', + caption: 'All Notification', + unread: 'Unread', + all: 'All', + read: 'Read', + viewALL: 'View All', + markAsRead: 'Mark as Read', + }, + form: { tm6: { transportation: 'Flight/Vehicle', @@ -1141,6 +1151,7 @@ export default { taskListNotFound: 'Task list cannot be found.', creditNoteNotFound: 'Credit note cannot be found.', debitNoteNotFound: 'Debit note cannot be found.', + notificationNotFound: 'Notification cannot be found.', productGroupIsUsed: 'Product group is in used.', productIsUsed: 'Product is in used.', diff --git a/src/i18n/tha.ts b/src/i18n/tha.ts index 9f59da2f..a5e566ce 100644 --- a/src/i18n/tha.ts +++ b/src/i18n/tha.ts @@ -241,6 +241,16 @@ export default { }, }, + noti: { + title: 'การแจ้งเตือน', + caption: 'การแจ้งเตือนทั้งหมด', + unread: 'ยังไม่ได้อ่าน', + all: 'ทั้งหมด', + read: 'อ่าน', + viewAll: 'ดูทั้งหมด', + markAsRead: 'ทำเครื่องหมายว่าอ่านแล้ว', + }, + form: { tm6: { transportation: 'เที่ยวบิน/พาหนะ', @@ -1119,6 +1129,7 @@ export default { taskListNotFound: 'ไม่พบใบสั่งงาน', creditNoteNotFound: 'ไม่พบใบลดหนี้', debitNoteNotFound: 'ไม่พบใบเพิ่มหนี้', + notificationNotFound: 'ไม่พบการแจ้งเตือน', productGroupIsUsed: 'กลุ่มสินค้าและบริการที่ใช้งานอยู่', productIsUsed: 'สินค้าและบริการใช้งานอยู่', diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 168b895d..e84c65ff 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -1,10 +1,11 @@ + + diff --git a/src/pages/00_notification/NotiDialog.vue b/src/pages/00_notification/NotiDialog.vue new file mode 100644 index 00000000..b15f8731 --- /dev/null +++ b/src/pages/00_notification/NotiDialog.vue @@ -0,0 +1,69 @@ + + 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 1243de88..cfeb63ba 100644 --- a/src/stores/notification/index.ts +++ b/src/stores/notification/index.ts @@ -4,7 +4,13 @@ import { api } from 'src/boot/axios'; import { PaginationResult } from 'src/types'; import { createDataRefBase } from '../utils'; -export type Notification = {}; +export type Notification = { + id: string; + title: string; + detail: string; + read?: boolean; + createdAt: string; +}; export const useNotification = defineStore('noti-store', () => { const state = createDataRefBase(); @@ -28,9 +34,12 @@ export const useNotification = defineStore('noti-store', () => { return res.data; } - async function updateNotification(paymentId: string, payload: Notification) { + async function updateNotification( + notificationId: string, + payload: Notification, + ) { const res = await api.put( - `/notification/${paymentId}`, + `/notification/${notificationId}`, payload, ); if (res.status >= 400) return null; @@ -45,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, @@ -52,5 +81,7 @@ export const useNotification = defineStore('noti-store', () => { getNotificationList, updateNotification, deleteNotification, + deleteMultiNotification, + markReadNotification, }; }); diff --git a/src/stores/utils/index.ts b/src/stores/utils/index.ts index 109bce33..84f504a7 100644 --- a/src/stores/utils/index.ts +++ b/src/stores/utils/index.ts @@ -532,7 +532,7 @@ export function createDataRefBase( defaultPageSize = 30, ) { return { - data: ref(), + data: ref([]), page: ref(defaultPage), pageMax: ref(defaultPageMax), pageSize: ref(defaultPageSize),