From 9da2c6b538b4df6604138c3eb93e4a1edf9b89cb Mon Sep 17 00:00:00 2001 From: ROSHAN GARG Date: Mon, 9 Sep 2024 09:51:09 +0530 Subject: [PATCH 1/3] 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} From 919fcb7e3cd0208376dc75e23fd30a46685414c9 Mon Sep 17 00:00:00 2001 From: ROSHAN GARG Date: Mon, 9 Sep 2024 10:14:28 +0530 Subject: [PATCH 2/3] added Orders files --- src/views/orders/ViewOrders.js | 1010 -------------------------------- 1 file changed, 1010 deletions(-) diff --git a/src/views/orders/ViewOrders.js b/src/views/orders/ViewOrders.js index 72784f4..7db94ce 100644 --- a/src/views/orders/ViewOrders.js +++ b/src/views/orders/ViewOrders.js @@ -1,1013 +1,3 @@ -// import React, { useState, useEffect, useRef } from "react"; -// import axios from "axios"; -// import { Link, useNavigate, useParams } from "react-router-dom"; -// import QRCode from "react-qr-code"; -// import { isAutheticated } from "src/auth"; -// import { useDispatch, useSelector } from "react-redux"; -// import { addItemsToCart } from "src/redux/Actions/cartAction"; -// import toast from "react-hot-toast"; -// import { cibBlackberry } from "@coreui/icons"; -// import Button from "@material-ui/core/Button"; - -// function ViewOrders() { -// const { status, id } = useParams(); -// const [success, setSuccess] = useState(true); - -// const { cartItems, subTotal, shippingCharge, tax, shipingInfo, total } = -// useSelector((state) => state.cart); - -// const AllStates = useSelector((state) => state); -// const getValue = useRef(); -// const getFranchiseeID = useRef(); -// const dispatch = useDispatch(); -// const navigate = useNavigate(); -// const printOrderRef = useRef(); -// const token = isAutheticated(); -// const [productData, setProductData] = useState([]); -// const [allFranchisee, setAllFranchisee] = useState([]); -// const [allTax, setAllTax] = useState([]); -// const [orderDetails, setOrderDetails] = useState(); - -// const [productDetails, setProductDetails] = useState(); -// const [loading, setLoading] = useState(true); -// const [orderId, setOrderId] = useState(null); -// const [orderStatus, setOrderStatus] = useState(""); -// // const [data, setData] = useState({ -// // product_Name: '', -// // address: '', -// // quantity: '', -// // contact_Number: '', -// // total_Price: '', -// // }) -// useEffect(() => { -// const getSingleOrder = async () => { -// setLoading(true); -// const res = await axios.get(`/api/order/getOne/${id}`, { -// headers: { -// "Access-Control-Allow-Origin": "*", -// Authorization: `Bearer ${token}`, -// }, -// }); -// if (res.data) { -// setLoading(false); -// setOrderId(res.data?.order?.order_id); -// setOrderDetails(res.data?.order); -// console.log("nnnnnnnnnnn", res.data?.order); -// // let options = { -// // Franchisee: res.data?.order?.shippingInfo?.Franchisee?._id, -// // name: res.data?.order?.shippingInfo?.name, - -// // contact_Number: res.data?.order?.shippingInfo?.contact_Number, -// // contact_Person_Name: res.data?.order?.shippingInfo?.contact_Person_Name, -// // address: res.data?.order?.shippingInfo?.address, -// // city: res.data?.order?.shippingInfo?.city, -// // price_Lable: res.data?.order?.shippingInfo?.Franchisee?.price_Lable, -// // state: res.data?.order?.shippingInfo?.state, -// // banner: res.data?.order?.shippingInfo?.Franchisee?.banner?.url, -// // // Franchisee_Url: res?.data?.data?.url -// // } -// // dispatch({ type: "addShippingInfo", payload: options }); -// // if (res.data?.order?.orderItems) { -// // res.data?.order?.orderItems.map((i, ind) => { -// // dispatch({ type: "addToCart", payload: i }); -// // dispatch({ type: "calculatePrice" }); - -// // }) -// // } -// } -// }; -// getSingleOrder(); -// }, [token]); - -// const handleChange = (e) => { -// if (e.target.type === "text") { -// setData((prev) => ({ ...prev, [e.target.id]: e.target.value })); -// } else { -// if (e.target.value === "") toast.error("please select status"); -// setOrderStatus(e.target.value); -// } -// }; -// const handleQuantityChange = (e) => { -// setData((prev) => ({ -// ...prev, -// quantity: e.target.value, -// total_Price: productDetails?.base_Price * e.target.value, -// })); -// }; -// // ------------------------------------------------------ - -// const handlechangestatus = () => { -// if (orderStatus === "dispatched") { -// 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 courierName = document.getElementById("input1").value.trim(); -// const TrackingID = document.getElementById("input2").value.trim(); - -// // Check if values are entered -// if (courierName === "" || TrackingID === "") { -// swal({ -// title: "Warning", -// text: "Please enter values Courier Name And Tracking ID", -// icon: "warning", -// button: "Ok", -// dangerMode: true, -// }); -// } else { -// axios -// .patch( -// `/api/order/change/status/${id}`, -// { -// status: orderStatus, -// courierName, -// TrackingID, -// sendemail: orderDetails?.user?.email, -// customerName: orderDetails?.user?.name, -// }, -// { -// 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 === "cancelled") { -// swal({ -// title: `Are you sure for ${orderStatus}?`, -// icon: "warning", -// content: { -// element: "div", -// attributes: { -// innerHTML: -// '

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

-//
-//
-// {orderDetails?.orderID && ( -// -//
Order ID : {orderDetails?.orderID}
{" "} -//
-// )} -//
-// {orderDetails?.courier_name && ( -//
-// -//
-// Courier Name: {orderDetails?.courier_name} -//
{" "} -//
-// Tracking ID : {orderDetails?.courier_tracking_id} -//
-//
-//
-// )} -// {orderDetails?.isDelivered && ( -//
-// -//
Delivered: Yes
{" "} -//
-// Delivered Date: {orderDetails?.DeliveredDate} -//
-//
-//
-// )} -//
-// {/* */} - -// -// -// -//
-//
-//
-//
-// {loading ? ( -//
-//
-// Loading... -//
-//
-// ) : ( -//
-//
-// {orderDetails?.shipingInfo !== null && ( -//
-//
-// {/*
-// -//
-// -// - -//
- -//
*/} - -//
-//
-// Products : {orderDetails?.orderItems?.length} -//
-//
- -// {orderDetails?.orderItems && -// orderDetails?.orderItems.map( -// (productDetails, i) => ( -//
-//
-//
-// {productDetails?.name} -//
-//
-//
-// {productDetails?.name} -//
-//
-//
-//
-// -// {" "} -// Quantity:{" "} -// {productDetails?.quantity} -// -//
-// {productDetails?.variant_Name ? ( -//

-// Variant : ₹ -// -// {productDetails?.variant_Name} -// -//

-// ) : ( -//

-// It`s Device -//

-// )} -//

-// Subtotal: ₹ -// {productDetails?.product_Subtotal} -//

-//
-//
-//

-// -// {productDetails?.variant_Name -// ? "Price:" -// : "Master Price"} -// {" "} -// ₹{productDetails?.price} -//

-// {productDetails?.gst_rate && ( -//

-// -// {productDetails?.variant_Name -// ? "GST Rate:" -// : "Master GST Rate:"}{" "} -// -// -// {productDetails?.gst_rate} % -// -//

-// )} -//

-// -// {productDetails?.variant_Name -// ? "GST:" -// : "Master GST:"}{" "} -// {" "} -// -// ₹{productDetails?.gst_amount} -// -//

-//
-//
-//
-//
-//
-//
-// ) -// )} -//
-//
-// Shipping Charge: {" "} -// ₹{orderDetails?.shipping_charge} -//
-// {orderDetails?.isCouponUsed && ( -//
-// Coupon_Code: -// {orderDetails?.couponUsed?.coupon_code} -//
-// )} -//
-//
-//
-// {" "} -// Total Amount: ₹ -// {Number(orderDetails?.total_amount) + -// Number( -// orderDetails?.couponUsed?.discount_amount -// ? orderDetails?.couponUsed -// ?.discount_amount -// : 0 -// )} -//
{" "} -// {orderDetails?.isCouponUsed && ( -// -// Coupon Discount:₹ -// {Number( -// orderDetails?.couponUsed?.discount_amount -// )} -// -// )} -//
-// {orderDetails?.isCouponUsed && ( -//
-// {" "} -// Total After Discount: ₹ -// {Number(orderDetails?.total_amount)} -//
-// )} -//
-//
-//
-//
-//
-// )} - -//
-//
-// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// {orderDetails?.status_timeline?.cancelled && ( -// -// -// -// -// -// )} -// {/* -// -// -// -// */} -// -//
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, -// }) -// : "-"} -//
-//
-//
-//
-//
-//
-//
-//
-// {orderDetails?.orderStatus !== "cancelled" ? ( -//
-// Order Status: {orderDetails?.orderStatus} -//
-// ) : ( -// <> -//
-// Order Status: {orderDetails?.orderStatus} -//
-//

-// {" "} -// Order Cancelled Reason:{" "} -// {orderDetails?.order_Cancelled_Reason} -//

-// -// )} -// {/* order status change */}{" "} -//
-// {" "} -// {status !== "cancelled" && -// status !== "returned" && -// status !== "delivered" && ( -//
-// -//
-//
-// -//
-// {orderStatus && ( -//
-// -//
-// )} -//
-//
-// )} -//
-// {/* */} -// -// {/*
-// -// -//
*/} -//
-// {orderDetails?.shipingInfo !== null && ( -//
-//
-// {/*
-// {orderDetails?.shippingInfo?.name} -//
*/} -//
-//
-// Name: {orderDetails?.shippingInfo?.first_Name}{" "} -// {orderDetails?.shippingInfo?.last_Name} -//
- -//

-// Contact No. :{" "} -// {orderDetails?.shippingInfo?.phone_Number} -//

-// -// street. : {orderDetails?.shippingInfo?.street} -// - -//

-// City : {orderDetails?.shippingInfo?.city} -//

-//

-// State : {orderDetails?.shippingInfo?.state} -//

-//

-// country : {orderDetails?.shippingInfo?.country} -//

-//

-// Postal Code. :{" "} -// {orderDetails?.shippingInfo?.postalCode} -//

-//
-//
-//
-//
-// )} -//
-// -//
-//
-// -//
- -//
-// -//
-//
-// -//
-//
-// -//
-//
-// -//
-//
-//
-//
-//
-// )} -//
-//
-//
-//
-// {/* */} -//
-// -// ); -// } - -// export default ViewOrders; import React, { useState, useEffect } from "react"; import { Box, From 9941d699f5d203cb111db439e04364494423c91a Mon Sep 17 00:00:00 2001 From: ROSHAN GARG Date: Mon, 9 Sep 2024 11:23:38 +0530 Subject: [PATCH 3/3] updated the index .js --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index 1ea46a1..32935e5 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,7 @@ import { createRoot } from "react-dom/client"; const setupAxios = () => { // axios.defaults.baseURL = "http://localhost:5000"; axios.defaults.baseURL = "https://cheminova-api-2.onrender.com"; + axios.defaults.baseURL = "https://api.cnapp.co.in"; axios.defaults.headers = { "Cache-Control": "no-cache,no-store",