diff --git a/src/api/00_dashboard/api.message.ts b/src/api/00_dashboard/api.message.ts index fefbcc22a..f4f8592f2 100644 --- a/src/api/00_dashboard/api.message.ts +++ b/src/api/00_dashboard/api.message.ts @@ -10,6 +10,7 @@ export default { msgNotificate: `${message}/my-notifications`, msgInbox: `${message}/my-inboxes`, msgId: (id: string) => `${message}/my-notifications/${id}`, + msgNoread: () => `${message}/my-notifications/noread`, msgInboxDelete: (id: string) => `${message}/my-inboxes/${id}`, replyMessage: (id: string) => `${reply}/${id}`, }; diff --git a/src/interface/request/main/main.ts b/src/interface/request/main/main.ts index d35aaf0be..b03e0d965 100644 --- a/src/interface/request/main/main.ts +++ b/src/interface/request/main/main.ts @@ -31,7 +31,8 @@ interface notiType { id: string; sender: string; body: string; - timereceive: Date; + timereceive: string; + isOpen: boolean; } interface optionType { diff --git a/src/interface/response/dashboard/dashboard.ts b/src/interface/response/dashboard/dashboard.ts index 601438691..dad38b36a 100644 --- a/src/interface/response/dashboard/dashboard.ts +++ b/src/interface/response/dashboard/dashboard.ts @@ -12,7 +12,7 @@ interface ResponseInbox { lastUpdateUserId: string; lastUpdatedAt: Date; openDate: Date | null; - payload: {attachments:attachments[]} + payload: { attachments: attachments[] }; receiveDate: Date; receiverUserId: string; subject: string; @@ -24,8 +24,9 @@ interface DataInbox { subject: string; timereceive: Date; body: string; - payload: {attachments:attachments[]} + payload: { attachments: attachments[] }; ratingModel: number; + isOpen: boolean; } export type { ResponseInbox, DataInbox }; diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index f44966864..b87b51092 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -54,11 +54,12 @@ const getData = async (index: number) => { body: e.body ?? "", payload: e.payload, ratingModel: 0, + isOpen: e.isOpen, }); }); inboxList.value.push(...list); - if (inboxList.value.length > 0) { + if (inboxList.value.length > 0 && index === 1) { selectInbox(inboxList.value[0].no); } }) @@ -71,8 +72,16 @@ const getData = async (index: number) => { }; const selectInbox = (id: string) => { - link.value = id; - data.value = inboxList.value.filter((r) => r.no == id); + http + .get(config.API.msgInboxDelete(id)) + .then(() => { + link.value = id; + data.value = inboxList.value.filter((r) => r.no == id); + for (const item of data.value) { + item.isOpen = true; + } + }) + .catch((err) => {}); }; const deleteData = (id: string) => { dialogRemove($q, () => removeData(id)); @@ -116,9 +125,13 @@ function onLoad(index: number, done: any) { setTimeout(() => { getData(num); done(); - }, 2000); + }, 1000); } } +const thaiOptions: Intl.DateTimeFormatOptions = { + hour: "2-digit", + minute: "2-digit", +}; @@ -138,8 +151,10 @@ function onLoad(index: number, done: any) { bordered :style="$q.screen.gt.xs ? 'height: 80vh' : 'height: auto;'" > -
+
กล่องข้อความ
+ +
ทั้งหมด {{ totalInbox }} ข้อความ
@@ -169,15 +184,28 @@ function onLoad(index: number, done: any) { @click="selectInbox(contact.no)" > - {{ - date2Thai(contact.timereceive) - }} - {{ - contact.sender - }} - {{ - contact.subject - }} + + {{ date2Thai(contact.timereceive) }} + {{ + new Date(contact.timereceive).toLocaleTimeString( + "th-TH", + thaiOptions + ) + }} + น. + + {{ contact.sender }} + {{ contact.subject }} +
- diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 803b73f2a..943cb2f8b 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -1,5 +1,5 @@ @@ -497,32 +520,33 @@ function onLoad(index: any, done: any) { flat size="13px" class="q-mx-md bg-grey-3" - :color="notiList.length === 0 ? 'grey-6' : 'grey-8'" - :disable="notiList.length === 0" + :color="totalNoti === 0 ? 'grey-6' : 'grey-8'" + :disable="totalNoti === 0" > - {{ totalInbox }} + {{ + totalNoti + }} -
+
การแจ้งเตือน
+ +
ทั้งหมด {{ totalInbox }} ข้อความ
@@ -539,7 +563,7 @@ function onLoad(index: any, done: any) { {{ date2Thai(n.timereceive) }}{{ n.timereceive }}