diff --git a/src/interface/response/dashboard/dashboard.ts b/src/interface/response/dashboard/dashboard.ts index e62164b33..142898843 100644 --- a/src/interface/response/dashboard/dashboard.ts +++ b/src/interface/response/dashboard/dashboard.ts @@ -2,6 +2,7 @@ interface attachments { name: string; url: string; isReport: boolean; + isTemplate: boolean; } interface ResponseInbox { body: string; @@ -30,4 +31,4 @@ interface DataInbox { isOpen: boolean; } -export type { ResponseInbox, DataInbox }; +export type { ResponseInbox, DataInbox, attachments }; diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 12fd7a588..762e01c62 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -11,6 +11,7 @@ import PopupReplyInbox from "@/components/Dialogs/PopupReplyInbox.vue"; import type { ResponseInbox, DataInbox, + attachments, } from "@/interface/response/dashboard/dashboard"; const $q = useQuasar(); @@ -114,14 +115,18 @@ const removeData = async (id: string) => { hideLoader(); }); }; -const fileOpen = (url: string, isReport: boolean, fileName: string) => { - if (isReport) { +const fileOpen = async (attachmentsData: attachments) => { + if (attachmentsData.isReport) { showLoader(); - http - .get(url) + await http + .get(attachmentsData.url) .then(async (res) => { - const data = res.data.result; - await genReport(data, fileName, "pdf"); + const result = res.data; + if (attachmentsData.isTemplate) { + await genReport(result.result, attachmentsData.name, "pdf"); + } else { + window.open(result.downloadUrl, "_blank"); + } }) .catch((err) => { messageError($q, err); @@ -130,7 +135,7 @@ const fileOpen = (url: string, isReport: boolean, fileName: string) => { hideLoader(); }); } else { - window.open(url, "_blank"); + window.open(attachmentsData.url, "_blank"); } }; @@ -363,10 +368,7 @@ const thaiOptions: Intl.DateTimeFormatOptions = { v-for="(link, num) in d.payload.attachments" :key="num" > - + {{ link.name }}