From 9da2c6b538b4df6604138c3eb93e4a1edf9b89cb Mon Sep 17 00:00:00 2001 From: ROSHAN GARG Date: Mon, 9 Sep 2024 09:51:09 +0530 Subject: [PATCH] updated addrees --- src/views/orders/ViewOrders.js | 103 ++++++++++++++++----------------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/src/views/orders/ViewOrders.js b/src/views/orders/ViewOrders.js index bb19801..72784f4 100644 --- a/src/views/orders/ViewOrders.js +++ b/src/views/orders/ViewOrders.js @@ -1123,55 +1123,52 @@ const ViewOrders = () => { `Order got cancelled due to${cancellationReason}`, "success" ); - navigate(`/orders/${orderStatus}/${id}`); + navigate(`/orders/${orderStatus}`); } - } - // else if (orderStatus === "dispatched") { - // const cancellationRes = await axios.patch( - // `/api/change/status/${id}`, - // { - // status: orderStatus, - // courierName, - // TrackingID: courierId, - // }, - // { - // headers: { - // "Access-Control-Allow-Origin": "*", - // Authorization: `Bearer ${token}`, - // }, - // } - // ); - // if (cancellationRes.status === 200) { - // Swal.fire("Order Status updated", `Order Dispatched`, "success"); + } else if (orderStatus === "dispatched") { + const cancellationRes = await axios.patch( + `/api/change/status/${id}`, + { + status: orderStatus, + courierName, + TrackingID: courierId, + }, + { + headers: { + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + } + ); + if (cancellationRes.status === 200) { + Swal.fire("Order Status updated", `Order Dispatched`, "success"); - // navigate(`/orders/${orderStatus}/${id}`); - // } - // } - // else if (orderStatus === "delivered") { - // if (!deliveryDate) { - // Swal.fire("Please enter the Delivery Date"); - // setOpenDeliveredDialog(false); - // return; - // } - // const cancellationRes = await axios.patch( - // `/api/change/status/${id}`, - // { - // status: orderStatus, - // DDate: deliveryDate, - // }, - // { - // headers: { - // "Access-Control-Allow-Origin": "*", - // Authorization: `Bearer ${token}`, - // }, - // } - // ); - // if (cancellationRes.status === 200) { - // Swal.fire("Order Status updated", `Order in processing`, "success"); - // navigate(`/orders/${orderStatus}/${id}`); - // } - // } - else if (orderStatus === "processing") { + navigate(`/orders/${orderStatus}`); + } + } else if (orderStatus === "delivered") { + if (!deliveryDate) { + Swal.fire("Please enter the Delivery Date"); + setOpenDeliveredDialog(false); + return; + } + const cancellationRes = await axios.patch( + `/api/change/status/${id}`, + { + status: orderStatus, + DDate: deliveryDate, + }, + { + headers: { + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + } + ); + if (cancellationRes.status === 200) { + Swal.fire("Order Status updated", `Order in processing`, "success"); + navigate(`/orders/${orderStatus}`); + } + } else if (orderStatus === "processing") { const cancellationRes = await axios.patch( `/api/change/status/${id}`, { @@ -1186,7 +1183,7 @@ const ViewOrders = () => { ); if (cancellationRes.status === 200) { Swal.fire("Order Status updated", `Order in processing`, "success"); - navigate(`/orders/${orderStatus}/${id}`); + navigate(`/orders/${orderStatus}`); } } } catch (error) { @@ -1280,11 +1277,11 @@ const ViewOrders = () => { Subtotal: ₹{item.price * item.quantity} - Tax ({item.GST}%): ₹ + GST ({item.GST}%): ₹ {((item.GST * item.price) / 100) * item.quantity} - - Total with Tax: ₹{" "} + + Total with GST: ₹{" "} {((item.GST * item.price) / 100) * item.quantity + item.price * item.quantity} @@ -1312,8 +1309,8 @@ const ViewOrders = () => { Total Subtotal: ₹{order?.subtotal} - Total Tax: ₹{order?.gstTotal} - + Total GST: ₹{order?.gstTotal} + Grand Total: ₹{order?.grandTotal}