order status
This commit is contained in:
parent
3ada9ea922
commit
41fe4c549c
126
src/_nav.js
126
src/_nav.js
@ -117,70 +117,70 @@ const _nav = [
|
|||||||
to: "/inventory",
|
to: "/inventory",
|
||||||
group: "Inventory",
|
group: "Inventory",
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavGroup,
|
component: CNavGroup,
|
||||||
// name: "Orders",
|
name: "Orders",
|
||||||
// icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
||||||
// group: "",
|
group: "",
|
||||||
|
|
||||||
// items: [
|
items: [
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: "New",
|
name: "New",
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: "/orders/new",
|
to: "/orders/new",
|
||||||
// group: "Orders",
|
group: "Orders",
|
||||||
// },
|
},
|
||||||
// // {
|
// {
|
||||||
// // component: CNavItem,
|
// component: CNavItem,
|
||||||
// // name: "Paid",
|
// name: "Paid",
|
||||||
// // icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// // to: "/orders/returned",
|
// to: "/orders/returned",
|
||||||
// // },
|
// },
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: "Processing",
|
name: "Processing",
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: "/orders/processing",
|
to: "/orders/processing",
|
||||||
// group: "Orders",
|
group: "Orders",
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: "Dispatched",
|
name: "Dispatched",
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: "/orders/dispatched",
|
to: "/orders/dispatched",
|
||||||
// group: "Orders",
|
group: "Orders",
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: "Delivered",
|
name: "Delivered",
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: "/orders/delivered",
|
to: "/orders/delivered",
|
||||||
// group: "Orders",
|
group: "Orders",
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// component: CNavItem,
|
component: CNavItem,
|
||||||
// name: "Cancelled",
|
name: "Cancelled",
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: "/orders/cancelled",
|
to: "/orders/cancelled",
|
||||||
// group: "Orders",
|
group: "Orders",
|
||||||
// },
|
},
|
||||||
// {
|
// {
|
||||||
// component: CNavItem,
|
// component: CNavItem,
|
||||||
// name: "In Store Cash Orders",
|
// name: "In Store Cash Orders",
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: "/inStoreCashOrders/new",
|
// to: "/inStoreCashOrders/new",
|
||||||
// group: "Orders",
|
// group: "Orders",
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// component: CNavItem,
|
// component: CNavItem,
|
||||||
// name: "In Store QRCode Orders",
|
// name: "In Store QRCode Orders",
|
||||||
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
// icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
// to: "/InStoreQRCodeOrders/new",
|
// to: "/InStoreQRCodeOrders/new",
|
||||||
// group: "Orders",
|
// group: "Orders",
|
||||||
// },
|
// },
|
||||||
// ],
|
],
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Settings",
|
name: "Settings",
|
||||||
|
@ -1,297 +1,497 @@
|
|||||||
|
// import React, { useState, useEffect } from "react";
|
||||||
|
// import { Link } from "react-router-dom";
|
||||||
|
// import axios from "axios";
|
||||||
|
// import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
|
// function CancelledOrders() {
|
||||||
|
// const token = isAutheticated();
|
||||||
|
// const [loading, setLoading] = useState(true);
|
||||||
|
// const [success, setSuccess] = useState(true);
|
||||||
|
// const [cancelledOrdersData, setCancelledOrdersData] = useState([]);
|
||||||
|
|
||||||
|
// const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
// const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
// const [showData, setShowData] = useState(cancelledOrdersData);
|
||||||
|
|
||||||
|
// const handleShowEntries = (e) => {
|
||||||
|
// setCurrentPage(1);
|
||||||
|
// setItemPerPage(e.target.value);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// function getProcessingOrder() {
|
||||||
|
// axios
|
||||||
|
// .get(`/api/order/getAll/cancelled`, {
|
||||||
|
// headers: {
|
||||||
|
// "Access-Control-Allow-Origin": "*",
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// setCancelledOrdersData(res.data.order);
|
||||||
|
// setLoading(false);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// console.log(err);
|
||||||
|
// setLoading(false);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// getProcessingOrder();
|
||||||
|
// }, []);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// const loadData = () => {
|
||||||
|
// const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
// const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
// setShowData(cancelledOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
// };
|
||||||
|
// loadData();
|
||||||
|
// }, [currentPage, itemPerPage, cancelledOrdersData]);
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <div className="main-content">
|
||||||
|
// <div className="page-content">
|
||||||
|
// <div className="container-fluid">
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-12">
|
||||||
|
// <div
|
||||||
|
// className="
|
||||||
|
// page-title-box
|
||||||
|
// d-flex
|
||||||
|
// align-items-center
|
||||||
|
// justify-content-between
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
// Cancelled Orders
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-lg-12">
|
||||||
|
// <div className="card">
|
||||||
|
// <div className="card-body">
|
||||||
|
// <div className="row ml-0 mr-0 mb-10">
|
||||||
|
// <div className="col-sm-12 col-md-12">
|
||||||
|
// <div className="dataTables_length">
|
||||||
|
// <label className="w-100">
|
||||||
|
// Show
|
||||||
|
// <select
|
||||||
|
// style={{ width: "10%" }}
|
||||||
|
// name=""
|
||||||
|
// onChange={(e) => handleShowEntries(e)}
|
||||||
|
// className="
|
||||||
|
// select-w
|
||||||
|
// custom-select custom-select-sm
|
||||||
|
// form-control form-control-sm
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <option value="10">10</option>
|
||||||
|
// <option value="25">25</option>
|
||||||
|
// <option value="50">50</option>
|
||||||
|
// <option value="100">100</option>
|
||||||
|
// </select>
|
||||||
|
// entries
|
||||||
|
// </label>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="table-responsive table-shoot mt-3">
|
||||||
|
// <table
|
||||||
|
// className="table table-centered table-nowrap"
|
||||||
|
// style={{ border: "1px solid" }}
|
||||||
|
// >
|
||||||
|
// <thead
|
||||||
|
// className="thead-light"
|
||||||
|
// style={{ background: "#ecdddd" }}
|
||||||
|
// >
|
||||||
|
// <tr>
|
||||||
|
// <th className="text-start">Order ID</th>
|
||||||
|
// <th className="text-start">Customer</th>
|
||||||
|
// <th className="text-start">Order value</th>
|
||||||
|
// <th className="text-start">Order At</th>
|
||||||
|
// <th className="text-start">Status</th>
|
||||||
|
// <th className="text-start">Actions</th>
|
||||||
|
// </tr>
|
||||||
|
// </thead>
|
||||||
|
// <tbody>
|
||||||
|
// {!loading && showData.length === 0 && (
|
||||||
|
// <tr className="text-center">
|
||||||
|
// <td colSpan="6">
|
||||||
|
// <h5>No Data Available</h5>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// )}
|
||||||
|
// {loading ? (
|
||||||
|
// <tr>
|
||||||
|
// <td className="text-center" colSpan="6">
|
||||||
|
// Loading...
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// ) : (
|
||||||
|
// showData.map((order, i) => {
|
||||||
|
// return (
|
||||||
|
// <tr key={i}>
|
||||||
|
// <td className="text-start">{order?.orderID}</td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {order?.user?.name}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// ₹{order?.total_amount}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {new Date(order?.paidAt).toLocaleString(
|
||||||
|
// "en-IN",
|
||||||
|
// {
|
||||||
|
// month: "short",
|
||||||
|
// day: "numeric",
|
||||||
|
// year: "numeric",
|
||||||
|
// hour: "2-digit",
|
||||||
|
// minute: "numeric",
|
||||||
|
// hour12: true,
|
||||||
|
// }
|
||||||
|
// )}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// <span className="badge text-bg-danger text-white">
|
||||||
|
// {order?.orderStatus}
|
||||||
|
// </span>
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
||||||
|
// <Link
|
||||||
|
// to={`/orders/${order.orderStatus}/${order._id}`}
|
||||||
|
// >
|
||||||
|
// <button
|
||||||
|
// style={{ color: "white" }}
|
||||||
|
// type="button"
|
||||||
|
// className="
|
||||||
|
// btn btn-primary btn-sm
|
||||||
|
// waves-effect waves-light
|
||||||
|
// btn-table
|
||||||
|
// ms-2 mt-1
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// View
|
||||||
|
// </button>
|
||||||
|
// </Link>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// );
|
||||||
|
// })
|
||||||
|
// )}
|
||||||
|
// </tbody>
|
||||||
|
// </table>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="row mt-20">
|
||||||
|
// <div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
// <div
|
||||||
|
// className="dataTables_info"
|
||||||
|
// id="datatable_info"
|
||||||
|
// role="status"
|
||||||
|
// aria-live="polite"
|
||||||
|
// >
|
||||||
|
// Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
// {Math.min(
|
||||||
|
// currentPage * itemPerPage,
|
||||||
|
// cancelledOrdersData.length
|
||||||
|
// )}{" "}
|
||||||
|
// of {cancelledOrdersData.length} entries
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="col-sm-12 col-md-6">
|
||||||
|
// <div className="d-flex">
|
||||||
|
// <ul className="pagination ms-auto">
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// currentPage === 1
|
||||||
|
// ? "paginate_button page-item previous disabled"
|
||||||
|
// : "paginate_button page-item previous"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
// >
|
||||||
|
// Previous
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(currentPage - 1 < 1) && (
|
||||||
|
// <li className="paginate_button page-item">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={(e) =>
|
||||||
|
// setCurrentPage((prev) => prev - 1)
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// {currentPage - 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li className="paginate_button page-item active">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// >
|
||||||
|
// {currentPage}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// cancelledOrdersData.length - 1
|
||||||
|
// ) && (
|
||||||
|
// <li className="paginate_button page-item ">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => {
|
||||||
|
// setCurrentPage((prev) => prev + 1);
|
||||||
|
// }}
|
||||||
|
// >
|
||||||
|
// {currentPage + 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// !(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// cancelledOrdersData.length - 1
|
||||||
|
// )
|
||||||
|
// ? "paginate_button page-item next"
|
||||||
|
// : "paginate_button page-item next disabled"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
// >
|
||||||
|
// Next
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// </ul>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export default CancelledOrders;
|
||||||
|
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Paper,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableContainer,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
Typography,
|
||||||
|
TablePagination,
|
||||||
|
TextField,
|
||||||
|
MenuItem,
|
||||||
|
FormControl,
|
||||||
|
InputLabel,
|
||||||
|
Select,
|
||||||
|
Skeleton,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { isAutheticated } from "src/auth";
|
import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
function CancelledOrders() {
|
const CancelledOrders = () => {
|
||||||
const token = isAutheticated();
|
const [orders, setOrders] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [success, setSuccess] = useState(true);
|
const [page, setPage] = useState(0);
|
||||||
const [cancelledOrdersData, setCancelledOrdersData] = useState([]);
|
const [rowsPerPage, setRowsPerPage] = useState(5);
|
||||||
|
const [totalOrders, setTotalOrders] = useState(0);
|
||||||
|
const [searchField, setSearchField] = useState("Order ID");
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const token = isAutheticated();
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
// Fetch orders with pagination
|
||||||
const [itemPerPage, setItemPerPage] = useState(10);
|
const fetchOrders = async (page, limit) => {
|
||||||
const [showData, setShowData] = useState(cancelledOrdersData);
|
setLoading(true);
|
||||||
|
try {
|
||||||
const handleShowEntries = (e) => {
|
const response = await axios.get("/api/get-cancelled-order-admin", {
|
||||||
setCurrentPage(1);
|
headers: {
|
||||||
setItemPerPage(e.target.value);
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
page: page + 1, // Adjusting for zero-based index in the UI
|
||||||
|
limit,
|
||||||
|
searchField,
|
||||||
|
searchText,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
setOrders(response?.data?.cancelledOrders);
|
||||||
|
setTotalOrders(response?.data?.totalOrders);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching orders:", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function getProcessingOrder() {
|
fetchOrders(page, rowsPerPage);
|
||||||
axios
|
}, [page, rowsPerPage, searchField, searchText]);
|
||||||
.get(`/api/order/getAll/cancelled`, {
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
setCancelledOrdersData(res.data.order);
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
setLoading(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getProcessingOrder();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const handleSearchChange = (event) => {
|
||||||
const loadData = () => {
|
setSearchText(event.target.value);
|
||||||
const indexOfLastPost = currentPage * itemPerPage;
|
};
|
||||||
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
|
||||||
setShowData(cancelledOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
const handleSearchFieldChange = (event) => {
|
||||||
};
|
setSearchField(event.target.value);
|
||||||
loadData();
|
};
|
||||||
}, [currentPage, itemPerPage, cancelledOrdersData]);
|
|
||||||
|
const handleChangePage = (event, newPage) => {
|
||||||
|
setPage(newPage);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeRowsPerPage = (event) => {
|
||||||
|
setRowsPerPage(parseInt(event.target.value, 10));
|
||||||
|
setPage(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredOrders = orders?.filter((order) => {
|
||||||
|
if (searchField === "Order ID") {
|
||||||
|
return order.uniqueId.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
if (searchField === "Status") {
|
||||||
|
return order.status.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="main-content">
|
<Box>
|
||||||
<div className="page-content">
|
<Typography variant="h4" mb={2} textAlign="center">
|
||||||
<div className="container-fluid">
|
Cancelled Order Placed List
|
||||||
<div className="row">
|
</Typography>
|
||||||
<div className="col-12">
|
<Box display="flex" mb={2} alignItems="center">
|
||||||
<div
|
<FormControl variant="outlined" sx={{ minWidth: 150, mr: 2 }}>
|
||||||
className="
|
<InputLabel id="search-field-label">Search By</InputLabel>
|
||||||
page-title-box
|
<Select
|
||||||
d-flex
|
labelId="search-field-label"
|
||||||
align-items-center
|
id="search-field"
|
||||||
justify-content-between
|
value={searchField}
|
||||||
"
|
onChange={handleSearchFieldChange}
|
||||||
>
|
label="Search By"
|
||||||
<div style={{ fontSize: "22px" }} className="fw-bold">
|
>
|
||||||
Cancelled Orders
|
<MenuItem value="Order ID">Order ID</MenuItem>
|
||||||
</div>
|
<MenuItem value="Status">Status</MenuItem>
|
||||||
</div>
|
</Select>
|
||||||
</div>
|
</FormControl>
|
||||||
</div>
|
<TextField
|
||||||
<div className="row">
|
label={`Search by ${searchField}`}
|
||||||
<div className="col-lg-12">
|
variant="outlined"
|
||||||
<div className="card">
|
value={searchText}
|
||||||
<div className="card-body">
|
onChange={handleSearchChange}
|
||||||
<div className="row ml-0 mr-0 mb-10">
|
fullWidth
|
||||||
<div className="col-sm-12 col-md-12">
|
/>
|
||||||
<div className="dataTables_length">
|
</Box>
|
||||||
<label className="w-100">
|
<TableContainer component={Paper}>
|
||||||
Show
|
<Table>
|
||||||
<select
|
<TableHead>
|
||||||
style={{ width: "10%" }}
|
<TableRow>
|
||||||
name=""
|
<TableCell>Order ID</TableCell>
|
||||||
onChange={(e) => handleShowEntries(e)}
|
<TableCell>Order Date</TableCell>
|
||||||
className="
|
<TableCell>Items</TableCell>
|
||||||
select-w
|
<TableCell>Order Value</TableCell>
|
||||||
custom-select custom-select-sm
|
<TableCell>Status</TableCell>
|
||||||
form-control form-control-sm
|
<TableCell>Action</TableCell>
|
||||||
"
|
</TableRow>
|
||||||
>
|
</TableHead>
|
||||||
<option value="10">10</option>
|
<TableBody>
|
||||||
<option value="25">25</option>
|
{loading ? (
|
||||||
<option value="50">50</option>
|
Array.from(new Array(rowsPerPage)).map((_, index) => (
|
||||||
<option value="100">100</option>
|
<TableRow key={index}>
|
||||||
</select>
|
<TableCell colSpan={6}>
|
||||||
entries
|
<Skeleton height={40} />
|
||||||
</label>
|
</TableCell>
|
||||||
</div>
|
</TableRow>
|
||||||
</div>
|
))
|
||||||
</div>
|
) : filteredOrders.length > 0 ? (
|
||||||
|
filteredOrders.map((order) => (
|
||||||
<div className="table-responsive table-shoot mt-3">
|
<TableRow key={order._id}>
|
||||||
<table
|
<TableCell>{order.uniqueId}</TableCell>
|
||||||
className="table table-centered table-nowrap"
|
<TableCell>
|
||||||
style={{ border: "1px solid" }}
|
{new Date(order.createdAt).toDateString()}
|
||||||
|
<span>, {formatAMPM(order.createdAt)}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{order.orderItem.length}</TableCell>
|
||||||
|
<TableCell>{order.grandTotal.toFixed(2)}</TableCell>
|
||||||
|
<TableCell>{order.status}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() =>
|
||||||
|
navigate(`/orders/${order.status}/${order._id}`)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<thead
|
View
|
||||||
className="thead-light"
|
</Button>
|
||||||
style={{ background: "#ecdddd" }}
|
</TableCell>
|
||||||
>
|
</TableRow>
|
||||||
<tr>
|
))
|
||||||
<th className="text-start">Order ID</th>
|
) : (
|
||||||
<th className="text-start">Customer</th>
|
<TableRow>
|
||||||
<th className="text-start">Order value</th>
|
<TableCell colSpan={6} align="center">
|
||||||
<th className="text-start">Order At</th>
|
<Typography variant="body1">Data not found</Typography>
|
||||||
<th className="text-start">Status</th>
|
</TableCell>
|
||||||
<th className="text-start">Actions</th>
|
</TableRow>
|
||||||
</tr>
|
)}
|
||||||
</thead>
|
</TableBody>
|
||||||
<tbody>
|
</Table>
|
||||||
{!loading && showData.length === 0 && (
|
<TablePagination
|
||||||
<tr className="text-center">
|
rowsPerPageOptions={[5, 10, 25]}
|
||||||
<td colSpan="6">
|
component="div"
|
||||||
<h5>No Data Available</h5>
|
count={totalOrders}
|
||||||
</td>
|
rowsPerPage={rowsPerPage}
|
||||||
</tr>
|
page={page}
|
||||||
)}
|
onPageChange={handleChangePage}
|
||||||
{loading ? (
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||||
<tr>
|
/>
|
||||||
<td className="text-center" colSpan="6">
|
</TableContainer>
|
||||||
Loading...
|
</Box>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
) : (
|
|
||||||
showData.map((order, i) => {
|
|
||||||
return (
|
|
||||||
<tr key={i}>
|
|
||||||
<td className="text-start">{order?.orderID}</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{order?.user?.name}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
₹{order?.total_amount}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{new Date(order?.paidAt).toLocaleString(
|
|
||||||
"en-IN",
|
|
||||||
{
|
|
||||||
month: "short",
|
|
||||||
day: "numeric",
|
|
||||||
year: "numeric",
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "numeric",
|
|
||||||
hour12: true,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
<span className="badge text-bg-danger text-white">
|
|
||||||
{order?.orderStatus}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
|
||||||
<Link
|
|
||||||
to={`/orders/${order.orderStatus}/${order._id}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
style={{ color: "white" }}
|
|
||||||
type="button"
|
|
||||||
className="
|
|
||||||
btn btn-primary btn-sm
|
|
||||||
waves-effect waves-light
|
|
||||||
btn-table
|
|
||||||
ms-2 mt-1
|
|
||||||
"
|
|
||||||
>
|
|
||||||
View
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="row mt-20">
|
|
||||||
<div className="col-sm-12 col-md-6 mb-20">
|
|
||||||
<div
|
|
||||||
className="dataTables_info"
|
|
||||||
id="datatable_info"
|
|
||||||
role="status"
|
|
||||||
aria-live="polite"
|
|
||||||
>
|
|
||||||
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
|
||||||
{Math.min(
|
|
||||||
currentPage * itemPerPage,
|
|
||||||
cancelledOrdersData.length
|
|
||||||
)}{" "}
|
|
||||||
of {cancelledOrdersData.length} entries
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-sm-12 col-md-6">
|
|
||||||
<div className="d-flex">
|
|
||||||
<ul className="pagination ms-auto">
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
currentPage === 1
|
|
||||||
? "paginate_button page-item previous disabled"
|
|
||||||
: "paginate_button page-item previous"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev - 1)}
|
|
||||||
>
|
|
||||||
Previous
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(currentPage - 1 < 1) && (
|
|
||||||
<li className="paginate_button page-item">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={(e) =>
|
|
||||||
setCurrentPage((prev) => prev - 1)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{currentPage - 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li className="paginate_button page-item active">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
>
|
|
||||||
{currentPage}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
cancelledOrdersData.length - 1
|
|
||||||
) && (
|
|
||||||
<li className="paginate_button page-item ">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => {
|
|
||||||
setCurrentPage((prev) => prev + 1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{currentPage + 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
cancelledOrdersData.length - 1
|
|
||||||
)
|
|
||||||
? "paginate_button page-item next"
|
|
||||||
: "paginate_button page-item next disabled"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev + 1)}
|
|
||||||
>
|
|
||||||
Next
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Helper function to format time as AM/PM
|
||||||
|
const formatAMPM = (date) => {
|
||||||
|
var hours = new Date(date).getHours();
|
||||||
|
var minutes = new Date(date).getMinutes();
|
||||||
|
var ampm = hours >= 12 ? "PM" : "AM";
|
||||||
|
hours = hours % 12;
|
||||||
|
hours = hours ? hours : 12;
|
||||||
|
minutes = minutes < 10 ? "0" + minutes : minutes;
|
||||||
|
var strTime = hours + ":" + minutes + " " + ampm;
|
||||||
|
return strTime;
|
||||||
|
};
|
||||||
|
|
||||||
export default CancelledOrders;
|
export default CancelledOrders;
|
||||||
|
@ -1,297 +1,497 @@
|
|||||||
|
// import React, { useState, useEffect } from "react";
|
||||||
|
// import { Link } from "react-router-dom";
|
||||||
|
// import axios from "axios";
|
||||||
|
// import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
|
// function DeliveredOrders() {
|
||||||
|
// const token = isAutheticated();
|
||||||
|
// const [loading, setLoading] = useState(true);
|
||||||
|
// const [success, setSuccess] = useState(true);
|
||||||
|
// const [deliveredOrdersData, setDeliveredOrdersData] = useState([]);
|
||||||
|
|
||||||
|
// const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
// const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
// const [showData, setShowData] = useState(deliveredOrdersData);
|
||||||
|
|
||||||
|
// const handleShowEntries = (e) => {
|
||||||
|
// setCurrentPage(1);
|
||||||
|
// setItemPerPage(e.target.value);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// function getProcessingOrder() {
|
||||||
|
// axios
|
||||||
|
// .get(`/api/order/getAll/delivered`, {
|
||||||
|
// headers: {
|
||||||
|
// "Access-Control-Allow-Origin": "*",
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// setDeliveredOrdersData(res.data.order);
|
||||||
|
// setLoading(false);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// console.log(err);
|
||||||
|
// setLoading(false);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// getProcessingOrder();
|
||||||
|
// }, []);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// const loadData = () => {
|
||||||
|
// const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
// const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
// setShowData(deliveredOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
// };
|
||||||
|
// loadData();
|
||||||
|
// }, [currentPage, itemPerPage, deliveredOrdersData]);
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <div className="main-content">
|
||||||
|
// <div className="page-content">
|
||||||
|
// <div className="container-fluid">
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-12">
|
||||||
|
// <div
|
||||||
|
// className="
|
||||||
|
// page-title-box
|
||||||
|
// d-flex
|
||||||
|
// align-items-center
|
||||||
|
// justify-content-between
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
// Delivered Orders
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-lg-12">
|
||||||
|
// <div className="card">
|
||||||
|
// <div className="card-body">
|
||||||
|
// <div className="row ml-0 mr-0 mb-10">
|
||||||
|
// <div className="col-sm-12 col-md-12">
|
||||||
|
// <div className="dataTables_length">
|
||||||
|
// <label className="w-100">
|
||||||
|
// Show
|
||||||
|
// <select
|
||||||
|
// style={{ width: "10%" }}
|
||||||
|
// name=""
|
||||||
|
// onChange={(e) => handleShowEntries(e)}
|
||||||
|
// className="
|
||||||
|
// select-w
|
||||||
|
// custom-select custom-select-sm
|
||||||
|
// form-control form-control-sm
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <option value="10">10</option>
|
||||||
|
// <option value="25">25</option>
|
||||||
|
// <option value="50">50</option>
|
||||||
|
// <option value="100">100</option>
|
||||||
|
// </select>
|
||||||
|
// entries
|
||||||
|
// </label>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="table-responsive table-shoot mt-3">
|
||||||
|
// <table
|
||||||
|
// className="table table-centered table-nowrap"
|
||||||
|
// style={{ border: "1px solid" }}
|
||||||
|
// >
|
||||||
|
// <thead
|
||||||
|
// className="thead-light"
|
||||||
|
// style={{ background: "#ecdddd" }}
|
||||||
|
// >
|
||||||
|
// <tr>
|
||||||
|
// <th className="text-start">Order ID</th>
|
||||||
|
// <th className="text-start">Customer</th>
|
||||||
|
// <th className="text-start">Order value</th>
|
||||||
|
// <th className="text-start">Order At</th>
|
||||||
|
// <th className="text-start">Status</th>
|
||||||
|
// <th className="text-start">Actions</th>
|
||||||
|
// </tr>
|
||||||
|
// </thead>
|
||||||
|
// <tbody>
|
||||||
|
// {!loading && showData.length === 0 && (
|
||||||
|
// <tr className="text-center">
|
||||||
|
// <td colSpan="6">
|
||||||
|
// <h5>No Data Available</h5>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// )}
|
||||||
|
// {loading ? (
|
||||||
|
// <tr>
|
||||||
|
// <td className="text-center" colSpan="6">
|
||||||
|
// Loading...
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// ) : (
|
||||||
|
// showData.map((order, i) => {
|
||||||
|
// return (
|
||||||
|
// <tr key={i}>
|
||||||
|
// <td className="text-start">{order?.orderID}</td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {order?.user?.name}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// ₹{order?.total_amount}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {new Date(order?.paidAt).toLocaleString(
|
||||||
|
// "en-IN",
|
||||||
|
// {
|
||||||
|
// month: "short",
|
||||||
|
// day: "numeric",
|
||||||
|
// year: "numeric",
|
||||||
|
// hour: "2-digit",
|
||||||
|
// minute: "numeric",
|
||||||
|
// hour12: true,
|
||||||
|
// }
|
||||||
|
// )}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// <span className="badge text-bg-success text-white">
|
||||||
|
// {order?.orderStatus}
|
||||||
|
// </span>
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
||||||
|
// <Link
|
||||||
|
// to={`/orders/${order.orderStatus}/${order._id}`}
|
||||||
|
// >
|
||||||
|
// <button
|
||||||
|
// style={{ color: "white" }}
|
||||||
|
// type="button"
|
||||||
|
// className="
|
||||||
|
// btn btn-primary btn-sm
|
||||||
|
// waves-effect waves-light
|
||||||
|
// btn-table
|
||||||
|
// ms-2 mt-1
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// View
|
||||||
|
// </button>
|
||||||
|
// </Link>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// );
|
||||||
|
// })
|
||||||
|
// )}
|
||||||
|
// </tbody>
|
||||||
|
// </table>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="row mt-20">
|
||||||
|
// <div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
// <div
|
||||||
|
// className="dataTables_info"
|
||||||
|
// id="datatable_info"
|
||||||
|
// role="status"
|
||||||
|
// aria-live="polite"
|
||||||
|
// >
|
||||||
|
// Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
// {Math.min(
|
||||||
|
// currentPage * itemPerPage,
|
||||||
|
// deliveredOrdersData.length
|
||||||
|
// )}{" "}
|
||||||
|
// of {deliveredOrdersData.length} entries
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="col-sm-12 col-md-6">
|
||||||
|
// <div className="d-flex">
|
||||||
|
// <ul className="pagination ms-auto">
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// currentPage === 1
|
||||||
|
// ? "paginate_button page-item previous disabled"
|
||||||
|
// : "paginate_button page-item previous"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
// >
|
||||||
|
// Previous
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(currentPage - 1 < 1) && (
|
||||||
|
// <li className="paginate_button page-item">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={(e) =>
|
||||||
|
// setCurrentPage((prev) => prev - 1)
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// {currentPage - 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li className="paginate_button page-item active">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// >
|
||||||
|
// {currentPage}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// deliveredOrdersData.length - 1
|
||||||
|
// ) && (
|
||||||
|
// <li className="paginate_button page-item ">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => {
|
||||||
|
// setCurrentPage((prev) => prev + 1);
|
||||||
|
// }}
|
||||||
|
// >
|
||||||
|
// {currentPage + 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// !(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// deliveredOrdersData.length - 1
|
||||||
|
// )
|
||||||
|
// ? "paginate_button page-item next"
|
||||||
|
// : "paginate_button page-item next disabled"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
// >
|
||||||
|
// Next
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// </ul>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export default DeliveredOrders;
|
||||||
|
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Paper,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableContainer,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
Typography,
|
||||||
|
TablePagination,
|
||||||
|
TextField,
|
||||||
|
MenuItem,
|
||||||
|
FormControl,
|
||||||
|
InputLabel,
|
||||||
|
Select,
|
||||||
|
Skeleton,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { isAutheticated } from "src/auth";
|
import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
function DeliveredOrders() {
|
const DeliveredOrders = () => {
|
||||||
const token = isAutheticated();
|
const [orders, setOrders] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [success, setSuccess] = useState(true);
|
const [page, setPage] = useState(0);
|
||||||
const [deliveredOrdersData, setDeliveredOrdersData] = useState([]);
|
const [rowsPerPage, setRowsPerPage] = useState(5);
|
||||||
|
const [totalOrders, setTotalOrders] = useState(0);
|
||||||
|
const [searchField, setSearchField] = useState("Order ID");
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const token = isAutheticated();
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
// Fetch orders with pagination
|
||||||
const [itemPerPage, setItemPerPage] = useState(10);
|
const fetchOrders = async (page, limit) => {
|
||||||
const [showData, setShowData] = useState(deliveredOrdersData);
|
setLoading(true);
|
||||||
|
try {
|
||||||
const handleShowEntries = (e) => {
|
const response = await axios.get("/api/get-delivered-order-admin", {
|
||||||
setCurrentPage(1);
|
headers: {
|
||||||
setItemPerPage(e.target.value);
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
page: page + 1, // Adjusting for zero-based index in the UI
|
||||||
|
limit,
|
||||||
|
searchField,
|
||||||
|
searchText,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
setOrders(response?.data?.deliveredOrders);
|
||||||
|
setTotalOrders(response?.data?.totalOrders);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching orders:", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function getProcessingOrder() {
|
fetchOrders(page, rowsPerPage);
|
||||||
axios
|
}, [page, rowsPerPage, searchField, searchText]);
|
||||||
.get(`/api/order/getAll/delivered`, {
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
setDeliveredOrdersData(res.data.order);
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
setLoading(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getProcessingOrder();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const handleSearchChange = (event) => {
|
||||||
const loadData = () => {
|
setSearchText(event.target.value);
|
||||||
const indexOfLastPost = currentPage * itemPerPage;
|
};
|
||||||
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
|
||||||
setShowData(deliveredOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
const handleSearchFieldChange = (event) => {
|
||||||
};
|
setSearchField(event.target.value);
|
||||||
loadData();
|
};
|
||||||
}, [currentPage, itemPerPage, deliveredOrdersData]);
|
|
||||||
|
const handleChangePage = (event, newPage) => {
|
||||||
|
setPage(newPage);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeRowsPerPage = (event) => {
|
||||||
|
setRowsPerPage(parseInt(event.target.value, 10));
|
||||||
|
setPage(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredOrders = orders?.filter((order) => {
|
||||||
|
if (searchField === "Order ID") {
|
||||||
|
return order.uniqueId.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
if (searchField === "Status") {
|
||||||
|
return order.status.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="main-content">
|
<Box>
|
||||||
<div className="page-content">
|
<Typography variant="h4" mb={2} textAlign="center">
|
||||||
<div className="container-fluid">
|
Delivered Order Placed List
|
||||||
<div className="row">
|
</Typography>
|
||||||
<div className="col-12">
|
<Box display="flex" mb={2} alignItems="center">
|
||||||
<div
|
<FormControl variant="outlined" sx={{ minWidth: 150, mr: 2 }}>
|
||||||
className="
|
<InputLabel id="search-field-label">Search By</InputLabel>
|
||||||
page-title-box
|
<Select
|
||||||
d-flex
|
labelId="search-field-label"
|
||||||
align-items-center
|
id="search-field"
|
||||||
justify-content-between
|
value={searchField}
|
||||||
"
|
onChange={handleSearchFieldChange}
|
||||||
>
|
label="Search By"
|
||||||
<div style={{ fontSize: "22px" }} className="fw-bold">
|
>
|
||||||
Delivered Orders
|
<MenuItem value="Order ID">Order ID</MenuItem>
|
||||||
</div>
|
<MenuItem value="Status">Status</MenuItem>
|
||||||
</div>
|
</Select>
|
||||||
</div>
|
</FormControl>
|
||||||
</div>
|
<TextField
|
||||||
<div className="row">
|
label={`Search by ${searchField}`}
|
||||||
<div className="col-lg-12">
|
variant="outlined"
|
||||||
<div className="card">
|
value={searchText}
|
||||||
<div className="card-body">
|
onChange={handleSearchChange}
|
||||||
<div className="row ml-0 mr-0 mb-10">
|
fullWidth
|
||||||
<div className="col-sm-12 col-md-12">
|
/>
|
||||||
<div className="dataTables_length">
|
</Box>
|
||||||
<label className="w-100">
|
<TableContainer component={Paper}>
|
||||||
Show
|
<Table>
|
||||||
<select
|
<TableHead>
|
||||||
style={{ width: "10%" }}
|
<TableRow>
|
||||||
name=""
|
<TableCell>Order ID</TableCell>
|
||||||
onChange={(e) => handleShowEntries(e)}
|
<TableCell>Order Date</TableCell>
|
||||||
className="
|
<TableCell>Items</TableCell>
|
||||||
select-w
|
<TableCell>Order Value</TableCell>
|
||||||
custom-select custom-select-sm
|
<TableCell>Status</TableCell>
|
||||||
form-control form-control-sm
|
<TableCell>Action</TableCell>
|
||||||
"
|
</TableRow>
|
||||||
>
|
</TableHead>
|
||||||
<option value="10">10</option>
|
<TableBody>
|
||||||
<option value="25">25</option>
|
{loading ? (
|
||||||
<option value="50">50</option>
|
Array.from(new Array(rowsPerPage)).map((_, index) => (
|
||||||
<option value="100">100</option>
|
<TableRow key={index}>
|
||||||
</select>
|
<TableCell colSpan={6}>
|
||||||
entries
|
<Skeleton height={40} />
|
||||||
</label>
|
</TableCell>
|
||||||
</div>
|
</TableRow>
|
||||||
</div>
|
))
|
||||||
</div>
|
) : filteredOrders.length > 0 ? (
|
||||||
|
filteredOrders.map((order) => (
|
||||||
<div className="table-responsive table-shoot mt-3">
|
<TableRow key={order._id}>
|
||||||
<table
|
<TableCell>{order.uniqueId}</TableCell>
|
||||||
className="table table-centered table-nowrap"
|
<TableCell>
|
||||||
style={{ border: "1px solid" }}
|
{new Date(order.createdAt).toDateString()}
|
||||||
|
<span>, {formatAMPM(order.createdAt)}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{order.orderItem.length}</TableCell>
|
||||||
|
<TableCell>{order.grandTotal.toFixed(2)}</TableCell>
|
||||||
|
<TableCell>{order.status}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() =>
|
||||||
|
navigate(`/orders/${order.status}/${order._id}`)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<thead
|
View
|
||||||
className="thead-light"
|
</Button>
|
||||||
style={{ background: "#ecdddd" }}
|
</TableCell>
|
||||||
>
|
</TableRow>
|
||||||
<tr>
|
))
|
||||||
<th className="text-start">Order ID</th>
|
) : (
|
||||||
<th className="text-start">Customer</th>
|
<TableRow>
|
||||||
<th className="text-start">Order value</th>
|
<TableCell colSpan={6} align="center">
|
||||||
<th className="text-start">Order At</th>
|
<Typography variant="body1">Data not found</Typography>
|
||||||
<th className="text-start">Status</th>
|
</TableCell>
|
||||||
<th className="text-start">Actions</th>
|
</TableRow>
|
||||||
</tr>
|
)}
|
||||||
</thead>
|
</TableBody>
|
||||||
<tbody>
|
</Table>
|
||||||
{!loading && showData.length === 0 && (
|
<TablePagination
|
||||||
<tr className="text-center">
|
rowsPerPageOptions={[5, 10, 25]}
|
||||||
<td colSpan="6">
|
component="div"
|
||||||
<h5>No Data Available</h5>
|
count={totalOrders}
|
||||||
</td>
|
rowsPerPage={rowsPerPage}
|
||||||
</tr>
|
page={page}
|
||||||
)}
|
onPageChange={handleChangePage}
|
||||||
{loading ? (
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||||
<tr>
|
/>
|
||||||
<td className="text-center" colSpan="6">
|
</TableContainer>
|
||||||
Loading...
|
</Box>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
) : (
|
|
||||||
showData.map((order, i) => {
|
|
||||||
return (
|
|
||||||
<tr key={i}>
|
|
||||||
<td className="text-start">{order?.orderID}</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{order?.user?.name}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
₹{order?.total_amount}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{new Date(order?.paidAt).toLocaleString(
|
|
||||||
"en-IN",
|
|
||||||
{
|
|
||||||
month: "short",
|
|
||||||
day: "numeric",
|
|
||||||
year: "numeric",
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "numeric",
|
|
||||||
hour12: true,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
<span className="badge text-bg-success text-white">
|
|
||||||
{order?.orderStatus}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
|
||||||
<Link
|
|
||||||
to={`/orders/${order.orderStatus}/${order._id}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
style={{ color: "white" }}
|
|
||||||
type="button"
|
|
||||||
className="
|
|
||||||
btn btn-primary btn-sm
|
|
||||||
waves-effect waves-light
|
|
||||||
btn-table
|
|
||||||
ms-2 mt-1
|
|
||||||
"
|
|
||||||
>
|
|
||||||
View
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="row mt-20">
|
|
||||||
<div className="col-sm-12 col-md-6 mb-20">
|
|
||||||
<div
|
|
||||||
className="dataTables_info"
|
|
||||||
id="datatable_info"
|
|
||||||
role="status"
|
|
||||||
aria-live="polite"
|
|
||||||
>
|
|
||||||
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
|
||||||
{Math.min(
|
|
||||||
currentPage * itemPerPage,
|
|
||||||
deliveredOrdersData.length
|
|
||||||
)}{" "}
|
|
||||||
of {deliveredOrdersData.length} entries
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-sm-12 col-md-6">
|
|
||||||
<div className="d-flex">
|
|
||||||
<ul className="pagination ms-auto">
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
currentPage === 1
|
|
||||||
? "paginate_button page-item previous disabled"
|
|
||||||
: "paginate_button page-item previous"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev - 1)}
|
|
||||||
>
|
|
||||||
Previous
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(currentPage - 1 < 1) && (
|
|
||||||
<li className="paginate_button page-item">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={(e) =>
|
|
||||||
setCurrentPage((prev) => prev - 1)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{currentPage - 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li className="paginate_button page-item active">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
>
|
|
||||||
{currentPage}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
deliveredOrdersData.length - 1
|
|
||||||
) && (
|
|
||||||
<li className="paginate_button page-item ">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => {
|
|
||||||
setCurrentPage((prev) => prev + 1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{currentPage + 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
deliveredOrdersData.length - 1
|
|
||||||
)
|
|
||||||
? "paginate_button page-item next"
|
|
||||||
: "paginate_button page-item next disabled"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev + 1)}
|
|
||||||
>
|
|
||||||
Next
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Helper function to format time as AM/PM
|
||||||
|
const formatAMPM = (date) => {
|
||||||
|
var hours = new Date(date).getHours();
|
||||||
|
var minutes = new Date(date).getMinutes();
|
||||||
|
var ampm = hours >= 12 ? "PM" : "AM";
|
||||||
|
hours = hours % 12;
|
||||||
|
hours = hours ? hours : 12;
|
||||||
|
minutes = minutes < 10 ? "0" + minutes : minutes;
|
||||||
|
var strTime = hours + ":" + minutes + " " + ampm;
|
||||||
|
return strTime;
|
||||||
|
};
|
||||||
|
|
||||||
export default DeliveredOrders;
|
export default DeliveredOrders;
|
||||||
|
@ -1,300 +1,499 @@
|
|||||||
|
// import React, { useState, useEffect } from "react";
|
||||||
|
// import { Link } from "react-router-dom";
|
||||||
|
// import axios from "axios";
|
||||||
|
// import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
|
// function DispatchedOrders() {
|
||||||
|
// const token = isAutheticated();
|
||||||
|
// const [loading, setLoading] = useState(true);
|
||||||
|
// const [success, setSuccess] = useState(true);
|
||||||
|
// const [dispatchedOrdersData, setDispatchedOrdersData] = useState([]);
|
||||||
|
|
||||||
|
// const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
// const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
// const [showData, setShowData] = useState(dispatchedOrdersData);
|
||||||
|
|
||||||
|
// const handleShowEntries = (e) => {
|
||||||
|
// setCurrentPage(1);
|
||||||
|
// setItemPerPage(e.target.value);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// function getDispatchedOrder() {
|
||||||
|
// axios
|
||||||
|
// .get(`/api/order/getAll/dispatched`, {
|
||||||
|
// headers: {
|
||||||
|
// "Access-Control-Allow-Origin": "*",
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// setDispatchedOrdersData(res.data.order);
|
||||||
|
// console.log(res.data.order);
|
||||||
|
// setLoading(false);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// console.log(err);
|
||||||
|
// setLoading(false);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// getDispatchedOrder();
|
||||||
|
// }, []);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// const loadData = () => {
|
||||||
|
// const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
// const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
// setShowData(
|
||||||
|
// dispatchedOrdersData.slice(indexOfFirstPost, indexOfLastPost)
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
// loadData();
|
||||||
|
// }, [currentPage, itemPerPage, dispatchedOrdersData]);
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <div className="main-content">
|
||||||
|
// <div className="page-content">
|
||||||
|
// <div className="container-fluid">
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-12">
|
||||||
|
// <div
|
||||||
|
// className="
|
||||||
|
// page-title-box
|
||||||
|
// d-flex
|
||||||
|
// align-items-center
|
||||||
|
// justify-content-between
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
// Dispatched Orders
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-lg-12">
|
||||||
|
// <div className="card">
|
||||||
|
// <div className="card-body">
|
||||||
|
// <div className="row ml-0 mr-0 mb-10">
|
||||||
|
// <div className="col-sm-12 col-md-12">
|
||||||
|
// <div className="dataTables_length">
|
||||||
|
// <label className="w-100">
|
||||||
|
// Show
|
||||||
|
// <select
|
||||||
|
// style={{ width: "10%" }}
|
||||||
|
// name=""
|
||||||
|
// onChange={(e) => handleShowEntries(e)}
|
||||||
|
// className="
|
||||||
|
// select-w
|
||||||
|
// custom-select custom-select-sm
|
||||||
|
// form-control form-control-sm
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <option value="10">10</option>
|
||||||
|
// <option value="25">25</option>
|
||||||
|
// <option value="50">50</option>
|
||||||
|
// <option value="100">100</option>
|
||||||
|
// </select>
|
||||||
|
// entries
|
||||||
|
// </label>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="table-responsive table-shoot mt-3">
|
||||||
|
// <table
|
||||||
|
// className="table table-centered table-nowrap"
|
||||||
|
// style={{ border: "1px solid" }}
|
||||||
|
// >
|
||||||
|
// <thead
|
||||||
|
// className="thead-light"
|
||||||
|
// style={{ background: "#ecdddd" }}
|
||||||
|
// >
|
||||||
|
// <tr>
|
||||||
|
// <th className="text-start">Order ID</th>
|
||||||
|
// <th className="text-start">Customer</th>
|
||||||
|
// <th className="text-start">Order value</th>
|
||||||
|
// <th className="text-start">Order At</th>
|
||||||
|
// <th className="text-start">Status</th>
|
||||||
|
// <th className="text-start">Actions</th>
|
||||||
|
// </tr>
|
||||||
|
// </thead>
|
||||||
|
// <tbody>
|
||||||
|
// {!loading && showData.length === 0 && (
|
||||||
|
// <tr className="text-center">
|
||||||
|
// <td colSpan="6">
|
||||||
|
// <h5>No Data Available</h5>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// )}
|
||||||
|
// {loading ? (
|
||||||
|
// <tr>
|
||||||
|
// <td className="text-center" colSpan="6">
|
||||||
|
// Loading...
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// ) : (
|
||||||
|
// showData.map((order, i) => {
|
||||||
|
// return (
|
||||||
|
// <tr key={i}>
|
||||||
|
// <td className="text-start">{order?.orderID}</td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {order?.user?.name}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// ₹{order?.total_amount}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {new Date(order?.paidAt).toLocaleString(
|
||||||
|
// "en-IN",
|
||||||
|
// {
|
||||||
|
// month: "short",
|
||||||
|
// day: "numeric",
|
||||||
|
// year: "numeric",
|
||||||
|
// hour: "2-digit",
|
||||||
|
// minute: "numeric",
|
||||||
|
// hour12: true,
|
||||||
|
// }
|
||||||
|
// )}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// <span className="badge text-bg-info text-white">
|
||||||
|
// {order?.orderStatus}
|
||||||
|
// </span>
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
||||||
|
// <Link
|
||||||
|
// to={`/orders/${order.orderStatus}/${order._id}`}
|
||||||
|
// >
|
||||||
|
// <button
|
||||||
|
// style={{ color: "white" }}
|
||||||
|
// type="button"
|
||||||
|
// className="
|
||||||
|
// btn btn-primary btn-sm
|
||||||
|
// waves-effect waves-light
|
||||||
|
// btn-table
|
||||||
|
// ms-2 mt-1
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// View
|
||||||
|
// </button>
|
||||||
|
// </Link>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// );
|
||||||
|
// })
|
||||||
|
// )}
|
||||||
|
// </tbody>
|
||||||
|
// </table>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="row mt-20">
|
||||||
|
// <div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
// <div
|
||||||
|
// className="dataTables_info"
|
||||||
|
// id="datatable_info"
|
||||||
|
// role="status"
|
||||||
|
// aria-live="polite"
|
||||||
|
// >
|
||||||
|
// Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
// {Math.min(
|
||||||
|
// currentPage * itemPerPage,
|
||||||
|
// dispatchedOrdersData.length
|
||||||
|
// )}{" "}
|
||||||
|
// of {dispatchedOrdersData.length} entries
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="col-sm-12 col-md-6">
|
||||||
|
// <div className="d-flex">
|
||||||
|
// <ul className="pagination ms-auto">
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// currentPage === 1
|
||||||
|
// ? "paginate_button page-item previous disabled"
|
||||||
|
// : "paginate_button page-item previous"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
// >
|
||||||
|
// Previous
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(currentPage - 1 < 1) && (
|
||||||
|
// <li className="paginate_button page-item">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={(e) =>
|
||||||
|
// setCurrentPage((prev) => prev - 1)
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// {currentPage - 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li className="paginate_button page-item active">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// >
|
||||||
|
// {currentPage}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// dispatchedOrdersData.length - 1
|
||||||
|
// ) && (
|
||||||
|
// <li className="paginate_button page-item ">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => {
|
||||||
|
// setCurrentPage((prev) => prev + 1);
|
||||||
|
// }}
|
||||||
|
// >
|
||||||
|
// {currentPage + 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// !(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// dispatchedOrdersData.length - 1
|
||||||
|
// )
|
||||||
|
// ? "paginate_button page-item next"
|
||||||
|
// : "paginate_button page-item next disabled"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
// >
|
||||||
|
// Next
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// </ul>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export default DispatchedOrders;
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Paper,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableContainer,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
Typography,
|
||||||
|
TablePagination,
|
||||||
|
TextField,
|
||||||
|
MenuItem,
|
||||||
|
FormControl,
|
||||||
|
InputLabel,
|
||||||
|
Select,
|
||||||
|
Skeleton,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { isAutheticated } from "src/auth";
|
import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
function DispatchedOrders() {
|
const DispatchedOrders = () => {
|
||||||
const token = isAutheticated();
|
const [orders, setOrders] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [success, setSuccess] = useState(true);
|
const [page, setPage] = useState(0);
|
||||||
const [dispatchedOrdersData, setDispatchedOrdersData] = useState([]);
|
const [rowsPerPage, setRowsPerPage] = useState(5);
|
||||||
|
const [totalOrders, setTotalOrders] = useState(0);
|
||||||
|
const [searchField, setSearchField] = useState("Order ID");
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const token = isAutheticated();
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
// Fetch orders with pagination
|
||||||
const [itemPerPage, setItemPerPage] = useState(10);
|
const fetchOrders = async (page, limit) => {
|
||||||
const [showData, setShowData] = useState(dispatchedOrdersData);
|
setLoading(true);
|
||||||
|
try {
|
||||||
const handleShowEntries = (e) => {
|
const response = await axios.get("/api/get-dispatched-order-admin", {
|
||||||
setCurrentPage(1);
|
headers: {
|
||||||
setItemPerPage(e.target.value);
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
page: page + 1, // Adjusting for zero-based index in the UI
|
||||||
|
limit,
|
||||||
|
searchField,
|
||||||
|
searchText,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
setOrders(response?.data?.dispatchedOrders);
|
||||||
|
setTotalOrders(response?.data?.totalOrders);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching orders:", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function getDispatchedOrder() {
|
fetchOrders(page, rowsPerPage);
|
||||||
axios
|
}, [page, rowsPerPage, searchField, searchText]);
|
||||||
.get(`/api/order/getAll/dispatched`, {
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
setDispatchedOrdersData(res.data.order);
|
|
||||||
console.log(res.data.order);
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
setLoading(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getDispatchedOrder();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const handleSearchChange = (event) => {
|
||||||
const loadData = () => {
|
setSearchText(event.target.value);
|
||||||
const indexOfLastPost = currentPage * itemPerPage;
|
};
|
||||||
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
|
||||||
setShowData(
|
const handleSearchFieldChange = (event) => {
|
||||||
dispatchedOrdersData.slice(indexOfFirstPost, indexOfLastPost)
|
setSearchField(event.target.value);
|
||||||
);
|
};
|
||||||
};
|
|
||||||
loadData();
|
const handleChangePage = (event, newPage) => {
|
||||||
}, [currentPage, itemPerPage, dispatchedOrdersData]);
|
setPage(newPage);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeRowsPerPage = (event) => {
|
||||||
|
setRowsPerPage(parseInt(event.target.value, 10));
|
||||||
|
setPage(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredOrders = orders?.filter((order) => {
|
||||||
|
if (searchField === "Order ID") {
|
||||||
|
return order.uniqueId.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
if (searchField === "Status") {
|
||||||
|
return order.status.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="main-content">
|
<Box>
|
||||||
<div className="page-content">
|
<Typography variant="h4" mb={2} textAlign="center">
|
||||||
<div className="container-fluid">
|
Dispatched Order Placed List
|
||||||
<div className="row">
|
</Typography>
|
||||||
<div className="col-12">
|
<Box display="flex" mb={2} alignItems="center">
|
||||||
<div
|
<FormControl variant="outlined" sx={{ minWidth: 150, mr: 2 }}>
|
||||||
className="
|
<InputLabel id="search-field-label">Search By</InputLabel>
|
||||||
page-title-box
|
<Select
|
||||||
d-flex
|
labelId="search-field-label"
|
||||||
align-items-center
|
id="search-field"
|
||||||
justify-content-between
|
value={searchField}
|
||||||
"
|
onChange={handleSearchFieldChange}
|
||||||
>
|
label="Search By"
|
||||||
<div style={{ fontSize: "22px" }} className="fw-bold">
|
>
|
||||||
Dispatched Orders
|
<MenuItem value="Order ID">Order ID</MenuItem>
|
||||||
</div>
|
<MenuItem value="Status">Status</MenuItem>
|
||||||
</div>
|
</Select>
|
||||||
</div>
|
</FormControl>
|
||||||
</div>
|
<TextField
|
||||||
<div className="row">
|
label={`Search by ${searchField}`}
|
||||||
<div className="col-lg-12">
|
variant="outlined"
|
||||||
<div className="card">
|
value={searchText}
|
||||||
<div className="card-body">
|
onChange={handleSearchChange}
|
||||||
<div className="row ml-0 mr-0 mb-10">
|
fullWidth
|
||||||
<div className="col-sm-12 col-md-12">
|
/>
|
||||||
<div className="dataTables_length">
|
</Box>
|
||||||
<label className="w-100">
|
<TableContainer component={Paper}>
|
||||||
Show
|
<Table>
|
||||||
<select
|
<TableHead>
|
||||||
style={{ width: "10%" }}
|
<TableRow>
|
||||||
name=""
|
<TableCell>Order ID</TableCell>
|
||||||
onChange={(e) => handleShowEntries(e)}
|
<TableCell>Order Date</TableCell>
|
||||||
className="
|
<TableCell>Items</TableCell>
|
||||||
select-w
|
<TableCell>Order Value</TableCell>
|
||||||
custom-select custom-select-sm
|
<TableCell>Status</TableCell>
|
||||||
form-control form-control-sm
|
<TableCell>Action</TableCell>
|
||||||
"
|
</TableRow>
|
||||||
>
|
</TableHead>
|
||||||
<option value="10">10</option>
|
<TableBody>
|
||||||
<option value="25">25</option>
|
{loading ? (
|
||||||
<option value="50">50</option>
|
Array.from(new Array(rowsPerPage)).map((_, index) => (
|
||||||
<option value="100">100</option>
|
<TableRow key={index}>
|
||||||
</select>
|
<TableCell colSpan={6}>
|
||||||
entries
|
<Skeleton height={40} />
|
||||||
</label>
|
</TableCell>
|
||||||
</div>
|
</TableRow>
|
||||||
</div>
|
))
|
||||||
</div>
|
) : filteredOrders.length > 0 ? (
|
||||||
|
filteredOrders.map((order) => (
|
||||||
<div className="table-responsive table-shoot mt-3">
|
<TableRow key={order._id}>
|
||||||
<table
|
<TableCell>{order.uniqueId}</TableCell>
|
||||||
className="table table-centered table-nowrap"
|
<TableCell>
|
||||||
style={{ border: "1px solid" }}
|
{new Date(order.createdAt).toDateString()}
|
||||||
|
<span>, {formatAMPM(order.createdAt)}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{order.orderItem.length}</TableCell>
|
||||||
|
<TableCell>{order.grandTotal.toFixed(2)}</TableCell>
|
||||||
|
<TableCell>{order.status}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() =>
|
||||||
|
navigate(`/orders/${order.status}/${order._id}`)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<thead
|
View
|
||||||
className="thead-light"
|
</Button>
|
||||||
style={{ background: "#ecdddd" }}
|
</TableCell>
|
||||||
>
|
</TableRow>
|
||||||
<tr>
|
))
|
||||||
<th className="text-start">Order ID</th>
|
) : (
|
||||||
<th className="text-start">Customer</th>
|
<TableRow>
|
||||||
<th className="text-start">Order value</th>
|
<TableCell colSpan={6} align="center">
|
||||||
<th className="text-start">Order At</th>
|
<Typography variant="body1">Data not found</Typography>
|
||||||
<th className="text-start">Status</th>
|
</TableCell>
|
||||||
<th className="text-start">Actions</th>
|
</TableRow>
|
||||||
</tr>
|
)}
|
||||||
</thead>
|
</TableBody>
|
||||||
<tbody>
|
</Table>
|
||||||
{!loading && showData.length === 0 && (
|
<TablePagination
|
||||||
<tr className="text-center">
|
rowsPerPageOptions={[5, 10, 25]}
|
||||||
<td colSpan="6">
|
component="div"
|
||||||
<h5>No Data Available</h5>
|
count={totalOrders}
|
||||||
</td>
|
rowsPerPage={rowsPerPage}
|
||||||
</tr>
|
page={page}
|
||||||
)}
|
onPageChange={handleChangePage}
|
||||||
{loading ? (
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||||
<tr>
|
/>
|
||||||
<td className="text-center" colSpan="6">
|
</TableContainer>
|
||||||
Loading...
|
</Box>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
) : (
|
|
||||||
showData.map((order, i) => {
|
|
||||||
return (
|
|
||||||
<tr key={i}>
|
|
||||||
<td className="text-start">{order?.orderID}</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{order?.user?.name}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
₹{order?.total_amount}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{new Date(order?.paidAt).toLocaleString(
|
|
||||||
"en-IN",
|
|
||||||
{
|
|
||||||
month: "short",
|
|
||||||
day: "numeric",
|
|
||||||
year: "numeric",
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "numeric",
|
|
||||||
hour12: true,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
<span className="badge text-bg-info text-white">
|
|
||||||
{order?.orderStatus}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
|
||||||
<Link
|
|
||||||
to={`/orders/${order.orderStatus}/${order._id}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
style={{ color: "white" }}
|
|
||||||
type="button"
|
|
||||||
className="
|
|
||||||
btn btn-primary btn-sm
|
|
||||||
waves-effect waves-light
|
|
||||||
btn-table
|
|
||||||
ms-2 mt-1
|
|
||||||
"
|
|
||||||
>
|
|
||||||
View
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="row mt-20">
|
|
||||||
<div className="col-sm-12 col-md-6 mb-20">
|
|
||||||
<div
|
|
||||||
className="dataTables_info"
|
|
||||||
id="datatable_info"
|
|
||||||
role="status"
|
|
||||||
aria-live="polite"
|
|
||||||
>
|
|
||||||
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
|
||||||
{Math.min(
|
|
||||||
currentPage * itemPerPage,
|
|
||||||
dispatchedOrdersData.length
|
|
||||||
)}{" "}
|
|
||||||
of {dispatchedOrdersData.length} entries
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-sm-12 col-md-6">
|
|
||||||
<div className="d-flex">
|
|
||||||
<ul className="pagination ms-auto">
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
currentPage === 1
|
|
||||||
? "paginate_button page-item previous disabled"
|
|
||||||
: "paginate_button page-item previous"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev - 1)}
|
|
||||||
>
|
|
||||||
Previous
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(currentPage - 1 < 1) && (
|
|
||||||
<li className="paginate_button page-item">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={(e) =>
|
|
||||||
setCurrentPage((prev) => prev - 1)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{currentPage - 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li className="paginate_button page-item active">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
>
|
|
||||||
{currentPage}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
dispatchedOrdersData.length - 1
|
|
||||||
) && (
|
|
||||||
<li className="paginate_button page-item ">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => {
|
|
||||||
setCurrentPage((prev) => prev + 1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{currentPage + 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
dispatchedOrdersData.length - 1
|
|
||||||
)
|
|
||||||
? "paginate_button page-item next"
|
|
||||||
: "paginate_button page-item next disabled"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev + 1)}
|
|
||||||
>
|
|
||||||
Next
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Helper function to format time as AM/PM
|
||||||
|
const formatAMPM = (date) => {
|
||||||
|
var hours = new Date(date).getHours();
|
||||||
|
var minutes = new Date(date).getMinutes();
|
||||||
|
var ampm = hours >= 12 ? "PM" : "AM";
|
||||||
|
hours = hours % 12;
|
||||||
|
hours = hours ? hours : 12;
|
||||||
|
minutes = minutes < 10 ? "0" + minutes : minutes;
|
||||||
|
var strTime = hours + ":" + minutes + " " + ampm;
|
||||||
|
return strTime;
|
||||||
|
};
|
||||||
|
|
||||||
export default DispatchedOrders;
|
export default DispatchedOrders;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,301 +1,501 @@
|
|||||||
|
// import React, { useState, useEffect } from "react";
|
||||||
|
// import { Link } from "react-router-dom";
|
||||||
|
// import axios from "axios";
|
||||||
|
// import { isAutheticated } from "src/auth";
|
||||||
|
// import toast from "react-hot-toast";
|
||||||
|
|
||||||
|
// function ProcessingOrders() {
|
||||||
|
// const token = isAutheticated();
|
||||||
|
// const [loading, setLoading] = useState(true);
|
||||||
|
// const [success, setSuccess] = useState(true);
|
||||||
|
// const [processingOrdersData, setProcessingOrdersData] = useState([]);
|
||||||
|
|
||||||
|
// const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
// const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
// const [showData, setShowData] = useState(processingOrdersData);
|
||||||
|
|
||||||
|
// const handleShowEntries = (e) => {
|
||||||
|
// setCurrentPage(1);
|
||||||
|
// setItemPerPage(e.target.value);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// function getProcessingOrder() {
|
||||||
|
// axios
|
||||||
|
// .get(`/api/order/getAll/processing`, {
|
||||||
|
// headers: {
|
||||||
|
// "Access-Control-Allow-Origin": "*",
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// console.log(res.data.order);
|
||||||
|
// setProcessingOrdersData(res.data.order);
|
||||||
|
// setLoading(false);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// console.log(err);
|
||||||
|
// setLoading(false);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// getProcessingOrder();
|
||||||
|
// }, []);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// const loadData = () => {
|
||||||
|
// const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
// const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
// setShowData(
|
||||||
|
// processingOrdersData.slice(indexOfFirstPost, indexOfLastPost)
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
// loadData();
|
||||||
|
// }, [currentPage, itemPerPage, processingOrdersData]);
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <div className="main-content">
|
||||||
|
// <div className="page-content">
|
||||||
|
// <div className="container-fluid">
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-12">
|
||||||
|
// <div
|
||||||
|
// className="
|
||||||
|
// page-title-box
|
||||||
|
// d-flex
|
||||||
|
// align-items-center
|
||||||
|
// justify-content-between
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
// Processing Orders
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// <div className="row">
|
||||||
|
// <div className="col-lg-12">
|
||||||
|
// <div className="card">
|
||||||
|
// <div className="card-body">
|
||||||
|
// <div className="row ml-0 mr-0 mb-10">
|
||||||
|
// <div className="col-sm-12 col-md-12">
|
||||||
|
// <div className="dataTables_length">
|
||||||
|
// <label className="w-100">
|
||||||
|
// Show
|
||||||
|
// <select
|
||||||
|
// style={{ width: "10%" }}
|
||||||
|
// name=""
|
||||||
|
// onChange={(e) => handleShowEntries(e)}
|
||||||
|
// className="
|
||||||
|
// select-w
|
||||||
|
// custom-select custom-select-sm
|
||||||
|
// form-control form-control-sm
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// <option value="10">10</option>
|
||||||
|
// <option value="25">25</option>
|
||||||
|
// <option value="50">50</option>
|
||||||
|
// <option value="100">100</option>
|
||||||
|
// </select>
|
||||||
|
// entries
|
||||||
|
// </label>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="table-responsive table-shoot mt-3">
|
||||||
|
// <table
|
||||||
|
// className="table table-centered table-nowrap"
|
||||||
|
// style={{ border: "1px solid" }}
|
||||||
|
// >
|
||||||
|
// <thead
|
||||||
|
// className="thead-light"
|
||||||
|
// style={{ background: "#ecdddd" }}
|
||||||
|
// >
|
||||||
|
// <tr>
|
||||||
|
// <th className="text-start">Order ID</th>
|
||||||
|
// <th className="text-start">Customer</th>
|
||||||
|
// <th className="text-start">Order value</th>
|
||||||
|
// <th className="text-start">Order At</th>
|
||||||
|
// <th className="text-start">Status</th>
|
||||||
|
// <th className="text-start">Actions</th>
|
||||||
|
// </tr>
|
||||||
|
// </thead>
|
||||||
|
// <tbody>
|
||||||
|
// {!loading && showData.length === 0 && (
|
||||||
|
// <tr className="text-center">
|
||||||
|
// <td colSpan="6">
|
||||||
|
// <h5>No Data Available</h5>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// )}
|
||||||
|
// {loading ? (
|
||||||
|
// <tr>
|
||||||
|
// <td className="text-center" colSpan="6">
|
||||||
|
// Loading...
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// ) : (
|
||||||
|
// showData.map((order, i) => {
|
||||||
|
// return (
|
||||||
|
// <tr key={i}>
|
||||||
|
// <td className="text-start">{order?.orderID}</td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {order?.user?.name}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// ₹{order?.total_amount}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {new Date(order?.paidAt).toLocaleString(
|
||||||
|
// "en-IN",
|
||||||
|
// {
|
||||||
|
// month: "short",
|
||||||
|
// day: "numeric",
|
||||||
|
// year: "numeric",
|
||||||
|
// hour: "2-digit",
|
||||||
|
// minute: "numeric",
|
||||||
|
// hour12: true,
|
||||||
|
// }
|
||||||
|
// )}
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// <span className="badge text-bg-warning text-white">
|
||||||
|
// {order?.orderStatus}
|
||||||
|
// </span>
|
||||||
|
// </td>
|
||||||
|
// <td className="text-start">
|
||||||
|
// {/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
||||||
|
// <Link
|
||||||
|
// to={`/orders/${order.orderStatus}/${order._id}`}
|
||||||
|
// >
|
||||||
|
// <button
|
||||||
|
// style={{ color: "white" }}
|
||||||
|
// type="button"
|
||||||
|
// className="
|
||||||
|
// btn btn-primary btn-sm
|
||||||
|
// waves-effect waves-light
|
||||||
|
// btn-table
|
||||||
|
// ms-2 mt-1
|
||||||
|
// "
|
||||||
|
// >
|
||||||
|
// View
|
||||||
|
// </button>
|
||||||
|
// </Link>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// );
|
||||||
|
// })
|
||||||
|
// )}
|
||||||
|
// </tbody>
|
||||||
|
// </table>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="row mt-20">
|
||||||
|
// <div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
// <div
|
||||||
|
// className="dataTables_info"
|
||||||
|
// id="datatable_info"
|
||||||
|
// role="status"
|
||||||
|
// aria-live="polite"
|
||||||
|
// >
|
||||||
|
// Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
// {Math.min(
|
||||||
|
// currentPage * itemPerPage,
|
||||||
|
// processingOrdersData.length
|
||||||
|
// )}{" "}
|
||||||
|
// of {processingOrdersData.length} entries
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <div className="col-sm-12 col-md-6">
|
||||||
|
// <div className="d-flex">
|
||||||
|
// <ul className="pagination ms-auto">
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// currentPage === 1
|
||||||
|
// ? "paginate_button page-item previous disabled"
|
||||||
|
// : "paginate_button page-item previous"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
// >
|
||||||
|
// Previous
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(currentPage - 1 < 1) && (
|
||||||
|
// <li className="paginate_button page-item">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={(e) =>
|
||||||
|
// setCurrentPage((prev) => prev - 1)
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// {currentPage - 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li className="paginate_button page-item active">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// >
|
||||||
|
// {currentPage}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
|
||||||
|
// {!(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// processingOrdersData.length - 1
|
||||||
|
// ) && (
|
||||||
|
// <li className="paginate_button page-item ">
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => {
|
||||||
|
// setCurrentPage((prev) => prev + 1);
|
||||||
|
// }}
|
||||||
|
// >
|
||||||
|
// {currentPage + 1}
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// )}
|
||||||
|
|
||||||
|
// <li
|
||||||
|
// className={
|
||||||
|
// !(
|
||||||
|
// (currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
// processingOrdersData.length - 1
|
||||||
|
// )
|
||||||
|
// ? "paginate_button page-item next"
|
||||||
|
// : "paginate_button page-item next disabled"
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// <span
|
||||||
|
// className="page-link"
|
||||||
|
// style={{ cursor: "pointer" }}
|
||||||
|
// onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
// >
|
||||||
|
// Next
|
||||||
|
// </span>
|
||||||
|
// </li>
|
||||||
|
// </ul>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export default ProcessingOrders;
|
||||||
|
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Paper,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableContainer,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
Typography,
|
||||||
|
TablePagination,
|
||||||
|
TextField,
|
||||||
|
MenuItem,
|
||||||
|
FormControl,
|
||||||
|
InputLabel,
|
||||||
|
Select,
|
||||||
|
Skeleton,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { isAutheticated } from "src/auth";
|
import { isAutheticated } from "src/auth";
|
||||||
import toast from "react-hot-toast";
|
|
||||||
|
|
||||||
function ProcessingOrders() {
|
const ProcessingOrders = () => {
|
||||||
const token = isAutheticated();
|
const [orders, setOrders] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [success, setSuccess] = useState(true);
|
const [page, setPage] = useState(0);
|
||||||
const [processingOrdersData, setProcessingOrdersData] = useState([]);
|
const [rowsPerPage, setRowsPerPage] = useState(5);
|
||||||
|
const [totalOrders, setTotalOrders] = useState(0);
|
||||||
|
const [searchField, setSearchField] = useState("Order ID");
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const token = isAutheticated();
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
// Fetch orders with pagination
|
||||||
const [itemPerPage, setItemPerPage] = useState(10);
|
const fetchOrders = async (page, limit) => {
|
||||||
const [showData, setShowData] = useState(processingOrdersData);
|
setLoading(true);
|
||||||
|
try {
|
||||||
const handleShowEntries = (e) => {
|
const response = await axios.get("/api/get-processing-order-admin", {
|
||||||
setCurrentPage(1);
|
headers: {
|
||||||
setItemPerPage(e.target.value);
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
page: page + 1, // Adjusting for zero-based index in the UI
|
||||||
|
limit,
|
||||||
|
searchField,
|
||||||
|
searchText,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
setOrders(response?.data?.processingOrders);
|
||||||
|
setTotalOrders(response?.data?.totalOrders);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching orders:", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function getProcessingOrder() {
|
fetchOrders(page, rowsPerPage);
|
||||||
axios
|
}, [page, rowsPerPage, searchField, searchText]);
|
||||||
.get(`/api/order/getAll/processing`, {
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
console.log(res.data.order);
|
|
||||||
setProcessingOrdersData(res.data.order);
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
setLoading(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getProcessingOrder();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const handleSearchChange = (event) => {
|
||||||
const loadData = () => {
|
setSearchText(event.target.value);
|
||||||
const indexOfLastPost = currentPage * itemPerPage;
|
};
|
||||||
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
|
||||||
setShowData(
|
const handleSearchFieldChange = (event) => {
|
||||||
processingOrdersData.slice(indexOfFirstPost, indexOfLastPost)
|
setSearchField(event.target.value);
|
||||||
);
|
};
|
||||||
};
|
|
||||||
loadData();
|
const handleChangePage = (event, newPage) => {
|
||||||
}, [currentPage, itemPerPage, processingOrdersData]);
|
setPage(newPage);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeRowsPerPage = (event) => {
|
||||||
|
setRowsPerPage(parseInt(event.target.value, 10));
|
||||||
|
setPage(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredOrders = orders?.filter((order) => {
|
||||||
|
if (searchField === "Order ID") {
|
||||||
|
return order.uniqueId.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
if (searchField === "Status") {
|
||||||
|
return order.status.toLowerCase().includes(searchText.toLowerCase());
|
||||||
|
}
|
||||||
|
return orders;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="main-content">
|
<Box>
|
||||||
<div className="page-content">
|
<Typography variant="h4" mb={2} textAlign="center">
|
||||||
<div className="container-fluid">
|
Processing Order Placed List
|
||||||
<div className="row">
|
</Typography>
|
||||||
<div className="col-12">
|
<Box display="flex" mb={2} alignItems="center">
|
||||||
<div
|
<FormControl variant="outlined" sx={{ minWidth: 150, mr: 2 }}>
|
||||||
className="
|
<InputLabel id="search-field-label">Search By</InputLabel>
|
||||||
page-title-box
|
<Select
|
||||||
d-flex
|
labelId="search-field-label"
|
||||||
align-items-center
|
id="search-field"
|
||||||
justify-content-between
|
value={searchField}
|
||||||
"
|
onChange={handleSearchFieldChange}
|
||||||
>
|
label="Search By"
|
||||||
<div style={{ fontSize: "22px" }} className="fw-bold">
|
>
|
||||||
Processing Orders
|
<MenuItem value="Order ID">Order ID</MenuItem>
|
||||||
</div>
|
<MenuItem value="Status">Status</MenuItem>
|
||||||
</div>
|
</Select>
|
||||||
</div>
|
</FormControl>
|
||||||
</div>
|
<TextField
|
||||||
<div className="row">
|
label={`Search by ${searchField}`}
|
||||||
<div className="col-lg-12">
|
variant="outlined"
|
||||||
<div className="card">
|
value={searchText}
|
||||||
<div className="card-body">
|
onChange={handleSearchChange}
|
||||||
<div className="row ml-0 mr-0 mb-10">
|
fullWidth
|
||||||
<div className="col-sm-12 col-md-12">
|
/>
|
||||||
<div className="dataTables_length">
|
</Box>
|
||||||
<label className="w-100">
|
<TableContainer component={Paper}>
|
||||||
Show
|
<Table>
|
||||||
<select
|
<TableHead>
|
||||||
style={{ width: "10%" }}
|
<TableRow>
|
||||||
name=""
|
<TableCell>Order ID</TableCell>
|
||||||
onChange={(e) => handleShowEntries(e)}
|
<TableCell>Order Date</TableCell>
|
||||||
className="
|
<TableCell>Items</TableCell>
|
||||||
select-w
|
<TableCell>Order Value</TableCell>
|
||||||
custom-select custom-select-sm
|
<TableCell>Status</TableCell>
|
||||||
form-control form-control-sm
|
<TableCell>Action</TableCell>
|
||||||
"
|
</TableRow>
|
||||||
>
|
</TableHead>
|
||||||
<option value="10">10</option>
|
<TableBody>
|
||||||
<option value="25">25</option>
|
{loading ? (
|
||||||
<option value="50">50</option>
|
Array.from(new Array(rowsPerPage)).map((_, index) => (
|
||||||
<option value="100">100</option>
|
<TableRow key={index}>
|
||||||
</select>
|
<TableCell colSpan={6}>
|
||||||
entries
|
<Skeleton height={40} />
|
||||||
</label>
|
</TableCell>
|
||||||
</div>
|
</TableRow>
|
||||||
</div>
|
))
|
||||||
</div>
|
) : filteredOrders.length > 0 ? (
|
||||||
|
filteredOrders.map((order) => (
|
||||||
<div className="table-responsive table-shoot mt-3">
|
<TableRow key={order._id}>
|
||||||
<table
|
<TableCell>{order.uniqueId}</TableCell>
|
||||||
className="table table-centered table-nowrap"
|
<TableCell>
|
||||||
style={{ border: "1px solid" }}
|
{new Date(order.createdAt).toDateString()}
|
||||||
|
<span>, {formatAMPM(order.createdAt)}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{order.orderItem.length}</TableCell>
|
||||||
|
<TableCell>{order.grandTotal.toFixed(2)}</TableCell>
|
||||||
|
<TableCell>{order.status}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() =>
|
||||||
|
navigate(`/orders/${order.status}/${order._id}`)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<thead
|
View
|
||||||
className="thead-light"
|
</Button>
|
||||||
style={{ background: "#ecdddd" }}
|
</TableCell>
|
||||||
>
|
</TableRow>
|
||||||
<tr>
|
))
|
||||||
<th className="text-start">Order ID</th>
|
) : (
|
||||||
<th className="text-start">Customer</th>
|
<TableRow>
|
||||||
<th className="text-start">Order value</th>
|
<TableCell colSpan={6} align="center">
|
||||||
<th className="text-start">Order At</th>
|
<Typography variant="body1">Data not found</Typography>
|
||||||
<th className="text-start">Status</th>
|
</TableCell>
|
||||||
<th className="text-start">Actions</th>
|
</TableRow>
|
||||||
</tr>
|
)}
|
||||||
</thead>
|
</TableBody>
|
||||||
<tbody>
|
</Table>
|
||||||
{!loading && showData.length === 0 && (
|
<TablePagination
|
||||||
<tr className="text-center">
|
rowsPerPageOptions={[5, 10, 25]}
|
||||||
<td colSpan="6">
|
component="div"
|
||||||
<h5>No Data Available</h5>
|
count={totalOrders}
|
||||||
</td>
|
rowsPerPage={rowsPerPage}
|
||||||
</tr>
|
page={page}
|
||||||
)}
|
onPageChange={handleChangePage}
|
||||||
{loading ? (
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||||
<tr>
|
/>
|
||||||
<td className="text-center" colSpan="6">
|
</TableContainer>
|
||||||
Loading...
|
</Box>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
) : (
|
|
||||||
showData.map((order, i) => {
|
|
||||||
return (
|
|
||||||
<tr key={i}>
|
|
||||||
<td className="text-start">{order?.orderID}</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{order?.user?.name}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
₹{order?.total_amount}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{new Date(order?.paidAt).toLocaleString(
|
|
||||||
"en-IN",
|
|
||||||
{
|
|
||||||
month: "short",
|
|
||||||
day: "numeric",
|
|
||||||
year: "numeric",
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "numeric",
|
|
||||||
hour12: true,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
<span className="badge text-bg-warning text-white">
|
|
||||||
{order?.orderStatus}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="text-start">
|
|
||||||
{/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
|
||||||
<Link
|
|
||||||
to={`/orders/${order.orderStatus}/${order._id}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
style={{ color: "white" }}
|
|
||||||
type="button"
|
|
||||||
className="
|
|
||||||
btn btn-primary btn-sm
|
|
||||||
waves-effect waves-light
|
|
||||||
btn-table
|
|
||||||
ms-2 mt-1
|
|
||||||
"
|
|
||||||
>
|
|
||||||
View
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="row mt-20">
|
|
||||||
<div className="col-sm-12 col-md-6 mb-20">
|
|
||||||
<div
|
|
||||||
className="dataTables_info"
|
|
||||||
id="datatable_info"
|
|
||||||
role="status"
|
|
||||||
aria-live="polite"
|
|
||||||
>
|
|
||||||
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
|
||||||
{Math.min(
|
|
||||||
currentPage * itemPerPage,
|
|
||||||
processingOrdersData.length
|
|
||||||
)}{" "}
|
|
||||||
of {processingOrdersData.length} entries
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-sm-12 col-md-6">
|
|
||||||
<div className="d-flex">
|
|
||||||
<ul className="pagination ms-auto">
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
currentPage === 1
|
|
||||||
? "paginate_button page-item previous disabled"
|
|
||||||
: "paginate_button page-item previous"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev - 1)}
|
|
||||||
>
|
|
||||||
Previous
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(currentPage - 1 < 1) && (
|
|
||||||
<li className="paginate_button page-item">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={(e) =>
|
|
||||||
setCurrentPage((prev) => prev - 1)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{currentPage - 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li className="paginate_button page-item active">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
>
|
|
||||||
{currentPage}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
processingOrdersData.length - 1
|
|
||||||
) && (
|
|
||||||
<li className="paginate_button page-item ">
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => {
|
|
||||||
setCurrentPage((prev) => prev + 1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{currentPage + 1}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<li
|
|
||||||
className={
|
|
||||||
!(
|
|
||||||
(currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
processingOrdersData.length - 1
|
|
||||||
)
|
|
||||||
? "paginate_button page-item next"
|
|
||||||
: "paginate_button page-item next disabled"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="page-link"
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => setCurrentPage((prev) => prev + 1)}
|
|
||||||
>
|
|
||||||
Next
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Helper function to format time as AM/PM
|
||||||
|
const formatAMPM = (date) => {
|
||||||
|
var hours = new Date(date).getHours();
|
||||||
|
var minutes = new Date(date).getMinutes();
|
||||||
|
var ampm = hours >= 12 ? "PM" : "AM";
|
||||||
|
hours = hours % 12;
|
||||||
|
hours = hours ? hours : 12;
|
||||||
|
minutes = minutes < 10 ? "0" + minutes : minutes;
|
||||||
|
var strTime = hours + ":" + minutes + " " + ampm;
|
||||||
|
return strTime;
|
||||||
|
};
|
||||||
|
|
||||||
export default ProcessingOrders;
|
export default ProcessingOrders;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@ import ClipLoader from "react-spinners/ClipLoader";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
import swal from "sweetalert";
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user