From 8a4ae65025932b017a210fb7e7c172a4ceb5eb66 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 19 Jan 2024 13:58:14 +0700 Subject: [PATCH] load Inbox --- src/api/api.message.ts | 2 + src/modules/01_dashboard/views/Dashboard.vue | 76 ++++-- src/views/MainLayout.vue | 246 +++++++++++-------- 3 files changed, 198 insertions(+), 126 deletions(-) diff --git a/src/api/api.message.ts b/src/api/api.message.ts index d7622a5..89eddc5 100644 --- a/src/api/api.message.ts +++ b/src/api/api.message.ts @@ -5,7 +5,9 @@ const reply = `${env.API_URI}/placement/noti`; export default { msgNotificate: `${message}/my-notifications`, + msgNotificateTotal: `${message}/my-notifications/noread`, msgInbox: `${message}/my-inboxes`, msgId: (id: string) => `${message}/my-notifications/${id}`, replyMessage: (id: string) => `${reply}/${id}`, + msgInboxRead: (id: string) => `${message}/my-inboxes/${id}`, }; diff --git a/src/modules/01_dashboard/views/Dashboard.vue b/src/modules/01_dashboard/views/Dashboard.vue index 35ce7da..2cfe962 100644 --- a/src/modules/01_dashboard/views/Dashboard.vue +++ b/src/modules/01_dashboard/views/Dashboard.vue @@ -11,7 +11,7 @@ import PopupDetailInbox from "@/components/PopupDetailInbox.vue"; const $q = useQuasar(); const mixin = useCounterMixin(); -const { showLoader, hideLoader, date2Thai } = mixin; +const { showLoader, hideLoader, date2Thai, messageError } = mixin; const fullname = ref("ธัญลักษณ์"); const inboxList = ref([ @@ -105,8 +105,9 @@ const fetchlistInbox = async (index: number) => { timereceive: date2Thai(e.createdAt), body: e.body ?? "-", ratingModel: 0, - receiveDate: date2Thai(e.receiveDate), + receiveDate: e.receiveDate, payload: e.payload, + isOpen: e.isOpen, }); }); inboxList.value.push(...listItem); @@ -138,10 +139,25 @@ function modalReplyClose() { const dataInbox = ref(); const modalDetial = ref(false); -function onClickOpenPopupDetail(data: any) { - dataInbox.value = data; - link.value = data.no; - modalDetial.value = !modalDetial.value; +async function onClickOpenPopupDetail(data: any) { + showLoader(); + await http + .get(config.API.msgInboxRead(data.no)) + .then(() => { + const filterDate = inboxList.value.filter((r: any) => r.no == data.no); + for (const item of filterDate) { + item.isOpen = true; + } + dataInbox.value = data; + link.value = data.no; + modalDetial.value = !modalDetial.value; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } function updateModalDetail(val: boolean) { @@ -156,9 +172,13 @@ async function onLoad(index: number, done: any) { setTimeout(() => { fetchlistInbox(num); done(); - }, 2000); + }, 3000); } } +const thaiOptions: Intl.DateTimeFormatOptions = { + hour: "2-digit", + minute: "2-digit", +};