From e2a88321215d9c2fa481a84232db8c29ebe82f3b Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 3 Aug 2023 10:36:28 +0700 Subject: [PATCH] Fix report image --- edit-mode/function/ganttConfig.js | 7 ++++++- edit-mode/function/reportActivity.js | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/edit-mode/function/ganttConfig.js b/edit-mode/function/ganttConfig.js index a22ca2d..4370aa7 100644 --- a/edit-mode/function/ganttConfig.js +++ b/edit-mode/function/ganttConfig.js @@ -22,7 +22,12 @@ const axiosInstance = axios.create({ "Content-type": "application/json" } }); - +const axiosInstanceMultipart = axios.create({ + headers: { + "Content-Type": "multipart/form-data", + "Authorization": `Bearer ${token}`, + } +}); axiosInstance.interceptors.request.use(async (config) => { try { $("body").addClass("loading"); diff --git a/edit-mode/function/reportActivity.js b/edit-mode/function/reportActivity.js index 7c6d232..97baba6 100644 --- a/edit-mode/function/reportActivity.js +++ b/edit-mode/function/reportActivity.js @@ -426,8 +426,19 @@ $(document).ready(function () { .catch((error) => error.response); // console.log("cek result", result); + let reportId = result.data.data.report_id; + let imageFormData = new FormData(); + let image = formData.get("files"); + imageFormData.append("ref_id",reportId); + imageFormData.append("category", "report_activity"); + imageFormData.append("files", image, image.name); + + const resultImage = await axiosInstanceMultipart + .post(`${base_url}image/upload`, imageFormData) + .then(res => res) + .catch((error) => error.response); - if (result && result.status == 200) { + if (result && result.status == 200 && resultImage && resultImage.status == 200) { gantt.alert("Add report activity material Success!"); resetFormAddRaMaterial(); tableRaMaterialActual.draw();