intgrating order api modified
This commit is contained in:
parent
367a3c43e9
commit
a087939b25
@ -102,7 +102,7 @@ const ViewOrders = () => {
|
||||
const cancellationRes = await axios.put(
|
||||
`/api/cancel-order/${id}`,
|
||||
{
|
||||
ReasonforCancellation: cancellationReason,
|
||||
cancellationReason: cancellationReason,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
@ -163,12 +163,14 @@ const ViewOrders = () => {
|
||||
navigate(`/orders/${orderStatus}`);
|
||||
}
|
||||
} else if (orderStatus === "processing") {
|
||||
const processingOrderInvoice = order?.orderItem.map((item) => ({
|
||||
const processingOrderInvoice = order?.orderItem
|
||||
.filter((item) => item.remainingQuantity > 0) // Only include items with remainingQuantity > 0
|
||||
.map((item) => ({
|
||||
...item,
|
||||
productId: item.productId._id,
|
||||
processquantity: item.quantity,
|
||||
processquantity: item.remainingQuantity, // Add processquantity only for items with remainingQuantity > 0
|
||||
}));
|
||||
console.log("");
|
||||
console.log(processingOrderInvoice);
|
||||
const cancellationRes = await axios.post(
|
||||
`/api/processing-order`,
|
||||
{
|
||||
@ -208,31 +210,33 @@ const ViewOrders = () => {
|
||||
setOpnePartialModal(false);
|
||||
};
|
||||
const handlePartialProcess = async (availability) => {
|
||||
const prepareData = availability.map(
|
||||
({
|
||||
productId,
|
||||
SKU,
|
||||
name,
|
||||
categoryName,
|
||||
brandName,
|
||||
price,
|
||||
GST,
|
||||
HSN_Code,
|
||||
description,
|
||||
processquantity,
|
||||
}) => ({
|
||||
productId: productId._id,
|
||||
SKU,
|
||||
name,
|
||||
categoryName,
|
||||
brandName,
|
||||
price,
|
||||
GST,
|
||||
HSN_Code,
|
||||
description,
|
||||
processquantity,
|
||||
})
|
||||
);
|
||||
const prepareData = availability
|
||||
.filter(({ processquantity }) => processquantity > 0)
|
||||
.map(
|
||||
({
|
||||
productId,
|
||||
SKU,
|
||||
name,
|
||||
categoryName,
|
||||
brandName,
|
||||
price,
|
||||
GST,
|
||||
HSN_Code,
|
||||
description,
|
||||
processquantity,
|
||||
}) => ({
|
||||
productId: productId._id,
|
||||
SKU,
|
||||
name,
|
||||
categoryName,
|
||||
brandName,
|
||||
price,
|
||||
GST,
|
||||
HSN_Code,
|
||||
description,
|
||||
processquantity,
|
||||
})
|
||||
);
|
||||
console.log(prepareData);
|
||||
|
||||
try {
|
||||
@ -251,7 +255,7 @@ const ViewOrders = () => {
|
||||
);
|
||||
if (cancellationRes.status === 200) {
|
||||
Swal.fire("Order Status updated", `Order in processing`, "success");
|
||||
navigate(`/orders/${orderStatus}`);
|
||||
navigate(`/orders/pending`);
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire("Something went wrong ", error.message, "error");
|
||||
@ -528,6 +532,7 @@ const ViewOrders = () => {
|
||||
)}
|
||||
{status === "pending" && (
|
||||
<>
|
||||
<option value="">Pending</option>
|
||||
<option value="processing">Processing</option>
|
||||
<option value="partial-processing">
|
||||
Partial Processing
|
||||
|
Loading…
Reference in New Issue
Block a user