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();