update
This commit is contained in:
parent
f8a9673e24
commit
d197cb2c43
@ -57,15 +57,22 @@ const OpeningInventoryReports = () => {
|
|||||||
|
|
||||||
const handleDownloadReport = async () => {
|
const handleDownloadReport = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`/api/report/opening-inventory/download`, {
|
const response = await axios.get(
|
||||||
headers: {
|
`/api/report/opening-inventory/download`,
|
||||||
Authorization: `Bearer ${token}`,
|
{
|
||||||
},
|
headers: {
|
||||||
responseType: 'arraybuffer', // Ensure that we handle the response as binary data
|
Authorization: `Bearer ${token}`,
|
||||||
});
|
},
|
||||||
|
responseType: "arraybuffer", // Ensure that we handle the response as binary data
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Step 1: Convert the response data into a Blob
|
// 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' }));
|
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
|
// Step 2: Create a download link and trigger the download
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
@ -76,7 +83,7 @@ const OpeningInventoryReports = () => {
|
|||||||
|
|
||||||
// Step 3: Clean up
|
// Step 3: Clean up
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
window.URL.revokeObjectURL(url); // Clean up the Blob URL
|
window.URL.revokeObjectURL(url); // Clean up the Blob URL
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = err?.response?.data?.msg || "Something went wrong!";
|
const msg = err?.response?.data?.msg || "Something went wrong!";
|
||||||
swal({
|
swal({
|
||||||
@ -264,7 +271,7 @@ const OpeningInventoryReports = () => {
|
|||||||
Brand Name
|
Brand Name
|
||||||
</th>
|
</th>
|
||||||
<th className="text-start" style={{ width: "15%" }}>
|
<th className="text-start" style={{ width: "15%" }}>
|
||||||
Total At PDs & Retailers
|
Total At PDs & Retailers
|
||||||
</th>
|
</th>
|
||||||
<th className="text-start" style={{ width: "10%" }}>
|
<th className="text-start" style={{ width: "10%" }}>
|
||||||
All PDs
|
All PDs
|
||||||
@ -326,10 +333,14 @@ const OpeningInventoryReports = () => {
|
|||||||
{product.brand || "Brand Not selected"}
|
{product.brand || "Brand Not selected"}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{product.allPdAndRd}
|
{parseFloat(product.allPdAndRd).toFixed(2)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{parseFloat(product.allPDs).toFixed(2)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{parseFloat(product.allRDs).toFixed(2)}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">{product.allPDs}</td>
|
|
||||||
<td className="text-start">{product.allRDs}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
@ -328,10 +328,14 @@ const StockReports = () => {
|
|||||||
{product.brand || "Brand Not selected"}
|
{product.brand || "Brand Not selected"}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{product.allPdAndRd}
|
{parseFloat(product.allPdAndRd).toFixed(2)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{parseFloat(product.allPDs).toFixed(2)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{parseFloat(product.allRDs).toFixed(2)}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">{product.allPDs}</td>
|
|
||||||
<td className="text-start">{product.allRDs}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
Reference in New Issue
Block a user