diff --git a/src/views/Reports/OpeningInventoryReports.js b/src/views/Reports/OpeningInventoryReports.js index cf9306e..7f9e7a1 100644 --- a/src/views/Reports/OpeningInventoryReports.js +++ b/src/views/Reports/OpeningInventoryReports.js @@ -55,6 +55,40 @@ const OpeningInventoryReports = () => { } }; + const handleDownloadReport = async () => { + try { + const response = await axios.get(`/api/report/opening-inventory/download`, { + headers: { + Authorization: `Bearer ${token}`, + }, + responseType: 'arraybuffer', // Ensure that we handle the response as binary data + }); + + // Step 1: Convert the response data into a Blob + const url = window.URL.createObjectURL(new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })); + + // Step 2: Create a download link and trigger the download + const link = document.createElement("a"); + link.setAttribute("href", url); + link.setAttribute("download", "OpeningInventoryReport.xlsx"); + document.body.appendChild(link); + link.click(); + + // Step 3: Clean up + document.body.removeChild(link); + window.URL.revokeObjectURL(url); // Clean up the Blob URL + } catch (err) { + const msg = err?.response?.data?.msg || "Something went wrong!"; + swal({ + title: "Error", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + } + }; + const getCatagories = () => { axios .get(`/api/category/getCategories`, { @@ -193,6 +227,18 @@ const OpeningInventoryReports = () => { ))} +
+ +
diff --git a/src/views/Reports/StockReports .js b/src/views/Reports/StockReports .js index 5c4a979..882f3aa 100644 --- a/src/views/Reports/StockReports .js +++ b/src/views/Reports/StockReports .js @@ -102,7 +102,43 @@ const StockReports = () => { const handleSearchChange = () => { debouncedSearch(); }; + const handleDownloadReport = async () => { + try { + const response = await axios.get(`/api/report/stock/download`, { + headers: { + Authorization: `Bearer ${token}`, + }, + responseType: "arraybuffer", // Ensure that we handle the response as binary data + }); + // Step 1: Convert the response data into a Blob + const url = window.URL.createObjectURL( + new Blob([response.data], { + type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + }) + ); + + // Step 2: Create a download link and trigger the download + const link = document.createElement("a"); + link.setAttribute("href", url); + link.setAttribute("download", "StockReports.xlsx"); + document.body.appendChild(link); + link.click(); + + // Step 3: Clean up + document.body.removeChild(link); + window.URL.revokeObjectURL(url); // Clean up the Blob URL + } catch (err) { + const msg = err?.response?.data?.msg || "Something went wrong!"; + swal({ + title: "Error", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + } + }; return (
@@ -193,6 +229,18 @@ const StockReports = () => { ))}
+
+ +
diff --git a/src/views/configuration/MobileApp.js b/src/views/configuration/MobileApp.js index a30d5de..d1a1865 100644 --- a/src/views/configuration/MobileApp.js +++ b/src/views/configuration/MobileApp.js @@ -306,7 +306,7 @@ function MobileApp() { useEffect(() => { async function getConfiguration() { try { - const configDetails = await axios.get(`/api/config`, { + const configDetails = await axios.get(`/api/mobileapp/getall`, { headers: { Authorization: `Bearer ${token}`, }, @@ -333,7 +333,7 @@ function MobileApp() { if (TMApp) formData.append("TMApp", TMApp); try { - const response = await axios.post(`/api/config/mobile-app`, formData, { + const response = await axios.post(`/api/mobileapp/add`, formData, { headers: { Authorization: `Bearer ${token}`, "Content-Type": "multipart/form-data",