diff --git a/src/_nav.js b/src/_nav.js
index f9ab4c0..e1e9ac8 100644
--- a/src/_nav.js
+++ b/src/_nav.js
@@ -117,70 +117,70 @@ const _nav = [
to: "/inventory",
group: "Inventory",
},
- // {
- // component: CNavGroup,
- // name: "Orders",
- // icon:
Order ID | +//Customer | +//Order value | +//Order At | +//Status | +//Actions | +//
---|---|---|---|---|---|
+// No Data Available+// |
+// |||||
+// Loading... +// | +//|||||
{order?.orderID} | +//+// {order?.user?.name} +// | +//+// ₹{order?.total_amount} +// | +//+// {new Date(order?.paidAt).toLocaleString( +// "en-IN", +// { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// } +// )} +// | +//+// +// {order?.orderStatus} +// +// | +//+// {/* */} +// +// +// +// | +//
Order ID | +//Customer | +//Order value | +//Order At | +//Status | +//Actions | +//
---|---|---|---|---|---|
+// No Data Available+// |
+// |||||
+// Loading... +// | +//|||||
{order?.orderID} | +//+// {order?.user?.name} +// | +//+// ₹{order?.total_amount} +// | +//+// {new Date(order?.paidAt).toLocaleString( +// "en-IN", +// { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// } +// )} +// | +//+// +// {order?.orderStatus} +// +// | +//
+// {/* */}
+//
+// |
+//
Order ID | -Customer | -Order value | -Order At | -Status | -Actions | -
---|---|---|---|---|---|
- No Data Available- |
- |||||
- Loading... - | -|||||
{order?.orderID} | -- {order?.user?.name} - | -- ₹{order?.total_amount} - | -- {new Date(order?.paidAt).toLocaleString( - "en-IN", - { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - } - )} - | -- - {order?.orderStatus} - - | -
- {/* */}
-
- |
-
Order ID | +//Customer | +//Order value | +//Order At | +//Status | +//Actions | +//
---|---|---|---|---|---|
+// No Data Available+// |
+// |||||
+// Loading... +// | +//|||||
{order?.orderID} | +//+// {order?.user?.name} +// | +//+// ₹{order?.total_amount} +// | +//+// {new Date(order?.paidAt).toLocaleString( +// "en-IN", +// { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// } +// )} +// | +//+// +// {order?.orderStatus} +// +// | +//
+// {/* */}
+//
+// |
+//
Order ID | -Customer | -Order value | -Order At | -Status | -Actions | -
---|---|---|---|---|---|
- No Data Available- |
- |||||
- Loading... - | -|||||
{order?.orderID} | -- {order?.user?.name} - | -- ₹{order?.total_amount} - | -- {new Date(order?.paidAt).toLocaleString( - "en-IN", - { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - } - )} - | -- - {order?.orderStatus} - - | -
- {/* */}
-
- |
-
Order ID | +//Customer | +//Order value | +//Order At | +//Status | +//Actions | +//
---|---|---|---|---|---|
+// No Data Available+// |
+// |||||
+// Loading... +// | +//|||||
{order?.orderID} | +//+// {order?.user?.name} +// | +//+// ₹{order?.total_amount} +// | +//+// {new Date(order?.paidAt).toLocaleString( +// "en-IN", +// { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// } +// )} +// | +//+// +// {order?.orderStatus} +// +// | +//
+// {/* */}
+//
+// |
+//
Order ID | -Customer | -Order value | -Order At | -Status | -Actions | -
---|---|---|---|---|---|
- No Data Available- |
- |||||
- Loading... - | -|||||
{order?.orderID} | -- {order?.user?.name} - | -- ₹{order?.total_amount} - | -- {new Date(order?.paidAt).toLocaleString( - "en-IN", - { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - } - )} - | -- - {order?.orderStatus} - - | -
- {/* */}
-
- |
-
Order ID | +//Customer | +//Order value | +//Order At | +//Status | +//Actions | +//
---|---|---|---|---|---|
+// No Data Available+// |
+// |||||
+// Loading... +// | +//|||||
{order?.orderID} | +//+// {order?.user?.name} +// | +//+// ₹{order?.total_amount} +// | +//+// {new Date(order?.paidAt).toLocaleString( +// "en-IN", +// { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// } +// )} +// | +//+// +// {order?.orderStatus} +// +// | +//
+// {/* */}
+//
+// |
+//
Order ID | -Customer | -Order value | -Order At | -Status | -Actions | -
---|---|---|---|---|---|
- No Data Available- |
- |||||
- Loading... - | -|||||
{order?.orderID} | -- {order?.user?.name} - | -- ₹{order?.total_amount} - | -- {new Date(order?.paidAt).toLocaleString( - "en-IN", - { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - } - )} - | -- - {order?.orderStatus} - - | -
- {/* */}
-
- |
-
Reson for cancellation.?
', +// }, +// }, +// buttons: { +// Yes: { text: "Submit", value: true }, + +// Cancel: { text: "Cancel", value: "cancel" }, +// }, +// }).then((result) => { +// if (result === true) { +// // You have the input values, you can use them in your API call +// const ReasonforCancellation = document +// .getElementById("input1") +// .value.trim(); + +// // Check if values are entered +// if (ReasonforCancellation === "") { +// swal({ +// title: "Warning", +// text: "Please enter Reason for Cancellation", +// icon: "warning", +// button: "Ok", +// dangerMode: true, +// }); +// } else { +// axios +// .patch( +// `/api/order/change/status/${id}`, +// { +// status: orderStatus, +// ReasonforCancellation, +// }, +// { +// headers: { +// "Access-Control-Allow-Origin": "*", +// Authorization: `Bearer ${token}`, +// }, +// } +// ) +// .then((res) => { +// console.log("status"); +// toast.success( +// `Order status change ${status} to ${orderStatus}` +// ); +// // setSuccess((prev) => !prev); +// }) +// .catch((err) => { +// swal({ +// title: "Warning", +// text: err.response.data.message +// ? err.response.data.message +// : "Something went wrong!", +// icon: "error", +// button: "Retry", +// dangerMode: true, +// }); +// }); +// } +// } +// // else { +// // swal.close(); // Close the popup if canceled +// // } +// }); +// } else if (orderStatus === "delivered") { +// swal({ +// title: `Are you sure for ${orderStatus}?`, +// icon: "warning", +// content: { +// element: "div", +// attributes: { +// innerHTML: +// '', +// // '', +// }, +// }, +// buttons: { +// Yes: { text: "Submit", value: true }, + +// Cancel: { text: "Cancel", value: "cancel" }, +// }, +// }).then((result) => { +// if (result === true) { +// // You have the input values, you can use them in your API call +// const DDate = document.getElementById("input1").value.trim(); + +// // Check if values are entered +// if (DDate === "") { +// swal({ +// title: "Warning", +// text: "Please enter Delivered Date", +// icon: "warning", +// button: "Ok", +// dangerMode: true, +// }); +// } else { +// axios +// .patch( +// `/api/order/change/status/${id}`, +// { +// status: orderStatus, +// DDate, +// }, +// { +// headers: { +// "Access-Control-Allow-Origin": "*", +// Authorization: `Bearer ${token}`, +// }, +// } +// ) +// .then((res) => { +// console.log("status"); +// toast.success( +// `Order status change ${status} to ${orderStatus}` +// ); +// // setSuccess((prev) => !prev); +// }) +// .catch((err) => { +// swal({ +// title: "Warning", +// text: err.response.data.message +// ? err.response.data.message +// : "Something went wrong!", +// icon: "error", +// button: "Retry", +// dangerMode: true, +// }); +// }); +// } +// } +// // else { +// // swal.close(); // Close the popup if canceled +// // } +// }); +// } else { +// swal({ +// title: `Are you sure for ${orderStatus}?`, +// icon: "warning", + +// buttons: { +// Yes: { text: "Yes", value: true }, +// Cancel: { text: "Cancel", value: "cancel" }, +// }, +// }).then((value) => { +// if (value === true) { +// axios +// .patch( +// `/api/order/change/status/${id}`, +// { status: orderStatus }, +// { +// headers: { +// "Access-Control-Allow-Origin": "*", +// Authorization: `Bearer ${token}`, +// }, +// } +// ) +// .then((res) => { +// console.log("status"); +// toast.success(`order status change ${status} to ${orderStatus}`); +// // setSuccess((prev) => !prev); +// }) +// .catch((err) => { +// swal({ +// title: "Warning", +// text: err.response.data.message +// ? err.response.data.message +// : "Something went wrong!", +// icon: "error", +// button: "Retry", +// dangerMode: true, +// }); +// }); +// } +// }); +// } +// }; + +// function getBack() { +// navigate(`/orders/${status}`, { replace: true }); +// } + +// return ( +// <> +// {" "} +//View Order
+//+// Variant : ₹ +// +// {productDetails?.variant_Name} +// +//
+// ) : ( +//+// It`s Device +//
+// )} +//
+//
+//
+// +// {productDetails?.variant_Name +// ? "GST Rate:" +// : "Master GST Rate:"}{" "} +// +// +// {productDetails?.gst_rate} % +// +//
+// )} +//+// +// {productDetails?.variant_Name +// ? "GST:" +// : "Master GST:"}{" "} +// {" "} +// +// ₹{productDetails?.gst_amount} +// +//
+//Order Placed On | +//: | +//+// {orderDetails?.createdAt +// ? new Date( +// orderDetails?.createdAt +// ).toLocaleString("en-IN", { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// }) +// : new Date( +// productData?.placed_on +// ).toLocaleString("en-IN", { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// })} +// | +//
---|---|---|
+// Processing Started +// | +//: | +//+// {orderDetails?.status_timeline?.processing +// ? new Date( +// orderDetails?.status_timeline?.processing +// ).toLocaleString("en-IN", { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// }) +// : "-"} +// | +//
+// Dispatched On +// | +//: | +//+// {orderDetails?.status_timeline?.dispatched +// ? new Date( +// orderDetails?.status_timeline?.dispatched +// ).toLocaleString("en-IN", { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// }) +// : "-"} +// | +//
+// Delivered On +// | +//: | +//+// {orderDetails?.status_timeline?.delivered +// ? new Date( +// orderDetails?.status_timeline?.delivered +// ).toLocaleString("en-IN", { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// }) +// : "-"} +// | +//
+// Cancelled On +// | +//: | +//+// {orderDetails?.status_timeline?.cancelled +// ? new Date( +// orderDetails?.status_timeline?.cancelled +// ).toLocaleString("en-IN", { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// }) +// : "-"} +// | +//
Returned On | +//: | +//+// {orderDetails?.status_timeline?.returned +// ? new Date( +// orderDetails?.status_timeline?.returned +// ).toLocaleString("en-IN", { +// month: "short", +// day: "numeric", +// year: "numeric", +// hour: "2-digit", +// minute: "numeric", +// hour12: true, +// }) +// : "-"} +// | +//
+// {" "} +// Order Cancelled Reason:{" "} +// {orderDetails?.order_Cancelled_Reason} +//
+// > +// )} +// {/* order status change */}{" "} +//+// Contact No. :{" "} +// {orderDetails?.shippingInfo?.phone_Number} +//
+//+// City : {orderDetails?.shippingInfo?.city} +//
+//+// State : {orderDetails?.shippingInfo?.state} +//
+//+// country : {orderDetails?.shippingInfo?.country} +//
+//+// Postal Code. :{" "} +// {orderDetails?.shippingInfo?.postalCode} +//
+//Reson for cancellation.?
', - }, - }, - buttons: { - Yes: { text: "Submit", value: true }, - - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((result) => { - if (result === true) { - // You have the input values, you can use them in your API call - const ReasonforCancellation = document - .getElementById("input1") - .value.trim(); - - // Check if values are entered - if (ReasonforCancellation === "") { - swal({ - title: "Warning", - text: "Please enter Reason for Cancellation", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - } else { - axios - .patch( - `/api/order/change/status/${id}`, - { - status: orderStatus, - ReasonforCancellation, - }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - console.log("status"); - toast.success( - `Order status change ${status} to ${orderStatus}` - ); - // setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: err.response.data.message - ? err.response.data.message - : "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - } - // else { - // swal.close(); // Close the popup if canceled - // } - }); + setOpenCancelDialog(true); } else if (orderStatus === "delivered") { - swal({ - title: `Are you sure for ${orderStatus}?`, - icon: "warning", - content: { - element: "div", - attributes: { - innerHTML: - '', - // '', - }, - }, - buttons: { - Yes: { text: "Submit", value: true }, - - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((result) => { - if (result === true) { - // You have the input values, you can use them in your API call - const DDate = document.getElementById("input1").value.trim(); - - // Check if values are entered - if (DDate === "") { - swal({ - title: "Warning", - text: "Please enter Delivered Date", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - } else { - axios - .patch( - `/api/order/change/status/${id}`, - { - status: orderStatus, - DDate, - }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - console.log("status"); - toast.success( - `Order status change ${status} to ${orderStatus}` - ); - // setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: err.response.data.message - ? err.response.data.message - : "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - } - // else { - // swal.close(); // Close the popup if canceled - // } - }); + setOpenDeliveredDialog(true); } else { - swal({ - title: `Are you sure for ${orderStatus}?`, - icon: "warning", - - buttons: { - Yes: { text: "Yes", value: true }, - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((value) => { - if (value === true) { - axios - .patch( - `/api/order/change/status/${id}`, - { status: orderStatus }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - console.log("status"); - toast.success(`order status change ${status} to ${orderStatus}`); - // setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: err.response.data.message - ? err.response.data.message - : "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - }); + setOpenConfirmDialog(true); } }; - function getBack() { - navigate(`/orders/${status}`, { replace: true }); + const handleConfirmUpdate = async (e) => { + e.preventDefault(); + try { + if (orderStatus === "cancelled") { + if (!cancellationReason) { + Swal.fire("Please give the order cancellation reason"); + } + const cancellationRes = await axios.patch( + `/api/change/status/${id}`, + { + status: orderStatus, + ReasonforCancellation: cancellationReason, + }, + { + headers: { + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + } + ); + if (cancellationRes.status === 200) { + Swal.fire( + "Order Status updated", + `Order got cancelled due to${cancellationReason}`, + "success" + ); + navigate(`/orders/${orderStatus}/${id}`); + } + } + // 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") { + const cancellationRes = await axios.patch( + `/api/change/status/${id}`, + { + status: orderStatus, + }, + { + 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}`); + } + } + } catch (error) { + Swal.fire("Something went wrong ", error.message, "error"); + } + // Perform update logic here + setOpenConfirmDialog(false); + setOpenDispatchDialog(false); + setOpenCancelDialog(false); + setOpenDeliveredDialog(false); // Close delivered dialog + }; + + const handleCancel = async () => { + setOpenConfirmDialog(false); + setOpenDispatchDialog(false); + setOpenCancelDialog(false); + setOpenDeliveredDialog(false); // Close delivered dialog + }; + + const timelineData = [ + { event: "Order Placed On", date: order?.createdAt }, + { + event: "Processing Started", + date: order?.status_timeline?.processing || "-", + }, + { event: "Dispatched On", date: order?.status_timeline?.dispatched || "-" }, + { event: "Delivered On", date: order?.status_timeline?.delivered || "-" }, + ]; + + if (loading) { + returnView Order
-- Variant : ₹ - - {productDetails?.variant_Name} - -
- ) : ( -- It`s Device -
- )} -
-
-
- - {productDetails?.variant_Name - ? "GST Rate:" - : "Master GST Rate:"}{" "} - - - {productDetails?.gst_rate} % - -
- )} -- - {productDetails?.variant_Name - ? "GST:" - : "Master GST:"}{" "} - {" "} - - ₹{productDetails?.gst_amount} - -
-Order Placed On | -: | -- {orderDetails?.createdAt - ? new Date( - orderDetails?.createdAt - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : new Date( - productData?.placed_on - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - })} - | -
---|---|---|
- Processing Started - | -: | -- {orderDetails?.status_timeline?.processing - ? new Date( - orderDetails?.status_timeline?.processing - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} - | -
- Dispatched On - | -: | -- {orderDetails?.status_timeline?.dispatched - ? new Date( - orderDetails?.status_timeline?.dispatched - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} - | -
- Delivered On - | -: | -- {orderDetails?.status_timeline?.delivered - ? new Date( - orderDetails?.status_timeline?.delivered - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} - | -
- Cancelled On - | -: | -- {orderDetails?.status_timeline?.cancelled - ? new Date( - orderDetails?.status_timeline?.cancelled - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} - | -
Returned On | -: | -- {orderDetails?.status_timeline?.returned - ? new Date( - orderDetails?.status_timeline?.returned - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} - | -
- {" "} - Order Cancelled Reason:{" "} - {orderDetails?.order_Cancelled_Reason} -
- > - )} - {/* order status change */}{" "} -- Contact No. :{" "} - {orderDetails?.shippingInfo?.phone_Number} -
-- City : {orderDetails?.shippingInfo?.city} -
-- State : {orderDetails?.shippingInfo?.state} -
-- country : {orderDetails?.shippingInfo?.country} -
-- Postal Code. :{" "} - {orderDetails?.shippingInfo?.postalCode} -
-