bug fixed of opening inventory single product update
This commit is contained in:
parent
d197cb2c43
commit
9e25d6f37b
@ -184,12 +184,26 @@ const DistributorOpeningInventory = () => {
|
||||
|
||||
const handleSubmitStocks = async () => {
|
||||
try {
|
||||
const updatedProducts = allProductsData.map((product) => ({
|
||||
_id: product._id,
|
||||
SKU: product.SKU,
|
||||
name: product.name,
|
||||
openingInventory: updatedStocks[product.SKU] || product.stock,
|
||||
}));
|
||||
// const updatedProducts = allProductsData.map((product) => ({
|
||||
// _id: product._id,
|
||||
// SKU: product.SKU,
|
||||
// name: product.name,
|
||||
// openingInventory: updatedStocks[product.SKU] || product.stock,
|
||||
// }));
|
||||
// Filter and map only products whose stock was changed
|
||||
const updatedProducts = allProductsData
|
||||
.filter((product) => updatedStocks[product.SKU] !== undefined)
|
||||
.map((product) => ({
|
||||
_id: product._id,
|
||||
SKU: product.SKU,
|
||||
name: product.name,
|
||||
openingInventory: updatedStocks[product.SKU],
|
||||
}));
|
||||
|
||||
if (updatedProducts.length === 0) {
|
||||
swal("Info", "No stock changes to update.", "info");
|
||||
return;
|
||||
}
|
||||
// console.log(updatedProducts);
|
||||
// console.log(id);
|
||||
await axios.put(
|
||||
|
@ -38,7 +38,7 @@ const OpeningInventoryReports = () => {
|
||||
brand: brandRef.current?.value || "",
|
||||
},
|
||||
});
|
||||
// console.log(response.data);
|
||||
// console.log(response.data.data);
|
||||
setProductsData(response.data?.data || []);
|
||||
setTotalData(response.data?.pagination?.total || 0);
|
||||
} catch (err) {
|
||||
@ -84,6 +84,7 @@ const OpeningInventoryReports = () => {
|
||||
// Step 3: Clean up
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url); // Clean up the Blob URL
|
||||
toast.success("Report downloaded successfully!");
|
||||
} catch (err) {
|
||||
const msg = err?.response?.data?.msg || "Something went wrong!";
|
||||
swal({
|
||||
|
@ -128,6 +128,7 @@ const StockReports = () => {
|
||||
// Step 3: Clean up
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url); // Clean up the Blob URL
|
||||
toast.success("Report downloaded successfully!");
|
||||
} catch (err) {
|
||||
const msg = err?.response?.data?.msg || "Something went wrong!";
|
||||
swal({
|
||||
|
Loading…
Reference in New Issue
Block a user