From 289e6554950e5cc4fa8d095fdc75b10925c6e2e4 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:20:18 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B9=80=E0=B8=A7=E0=B8=A5?= =?UTF-8?q?=E0=B8=B2=20=E0=B8=81=E0=B8=B1=E0=B8=9A=20=E0=B8=AA=E0=B8=96?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B8=B0=E0=B8=AD=E0=B8=AD=E0=B8=99=E0=B9=84?= =?UTF-8?q?=E0=B8=A5=E0=B8=99=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../00_support/components/FormChat.vue | 56 ++++++++++++++++++- src/modules/00_support/store/Main.ts | 46 +++++---------- 2 files changed, 68 insertions(+), 34 deletions(-) diff --git a/src/modules/00_support/components/FormChat.vue b/src/modules/00_support/components/FormChat.vue index f5ebd2b01..d328aecc1 100644 --- a/src/modules/00_support/components/FormChat.vue +++ b/src/modules/00_support/components/FormChat.vue @@ -12,8 +12,36 @@ const content = ref(""); const searchInput = ref(""); const currentIssuePage = ref(1); const totalPageIssue = ref(); +const createdByUser = ref(""); const { scrollContainer } = storeToRefs(store); +function dateIssue(timestamp: string): string { + const parsedTimestamp = moment(timestamp); + const diff = moment().diff(parsedTimestamp); + + if (diff < 1000) { + return "just now"; + } else if (diff < 60000) { + return `${Math.floor(diff / 1000)}s`; + } else if (diff < 3600000) { + return `${Math.floor(diff / 60000)}m`; + } else if (diff < 86400000) { + return `${Math.floor(diff / 3600000)}h`; + } else { + const beYear = parsedTimestamp.year() + 543; + const formattedDate = parsedTimestamp.clone().year(beYear).format("DD MMM"); + return formattedDate; + } +} + +function getOnlineStatus(option: "icon" | "status", userId: string) { + const isOnline: boolean = store.userStatus.some((u) => + u.userId.includes(userId) + ); + if (option === "icon") return isOnline ? "green" : "grey"; + if (option === "status") return isOnline ? "ออนไลน์" : "ออฟไลน์"; +} + onMounted(async () => { await store.fetchIssue(); totalPageIssue.value = Math.ceil((store.currentTotalIssue || 0) / 30); @@ -29,11 +57,16 @@ const onLoad = (async (_: any, done: any) => {