import React, { useEffect, useState } from "react"; import { CRow, CCol, CDropdown, CDropdownMenu, CDropdownItem, CDropdownToggle, CWidgetStatsA, } from "@coreui/react"; import { getStyle } from "@coreui/utils"; import { CChartBar, CChartLine } from "@coreui/react-chartjs"; import CIcon from "@coreui/icons-react"; import { cilArrowBottom, cilArrowTop, cilOptions } from "@coreui/icons"; import { BeatLoader } from "react-spinners"; import { isAutheticated } from "src/auth"; import axios from "axios"; { /* */ } const WidgetsDropdown = ({ users,salescoordinator,territorymanager }) => { // const WidgetsDropdown = ({ users, category, product, Requests }) => { // const token = isAutheticated(); // const [orders, setOrders] = useState([]); // const [todayorders, setTodayOrders] = useState([]); // const [monthorders, setMonthOrders] = useState([]); // const [yearorders, setYearOrders] = useState([]); // const [lastyearorders, setLastYearOrders] = useState([]); // const [processingorders, setProcessingOrders] = useState([]); // const [dispatchedorders, setDispatchedOrders] = useState([]); // const [deliveredorders, setDeliveredOrders] = useState([]); // const [cancelledorders, setCancelledOrders] = useState([]); // const getAllOrder = async () => { // let res = await axios.get(`/api/order/getAll/`, { // headers: { // Authorization: `Bearer ${token}`, // }, // }); // // console.log(res.data); // setOrders(res?.data?.order); // setTodayOrders( // res?.data?.order?.filter((order) => { // return ( // new Date(order.createdAt).toDateString() === new Date().toDateString() // ); // }) // ); // setMonthOrders( // res?.data?.order?.filter((order) => { // return new Date(order.createdAt).getMonth() === new Date().getMonth(); // }) // ); // setYearOrders( // res?.data?.order?.filter((order) => { // return ( // new Date(order.createdAt).getFullYear() === new Date().getFullYear() // ); // }) // ); // setLastYearOrders( // res?.data?.order?.filter((order) => { // return ( // new Date(order.createdAt).getFullYear() === // new Date().getFullYear() - 1 // ); // }) // ); // }; // const getProcessingOrder = async () => { // let res = await axios.get(`/api/order/getAll/processing`, { // headers: { // Authorization: `Bearer ${token}`, // }, // }); // // console.log(res.data); // setProcessingOrders(res?.data?.order); // }; // const getDispatchedOrder = async () => { // let res = await axios.get(`/api/order/getAll/dispatched`, { // headers: { // Authorization: `Bearer ${token}`, // }, // }); // // console.log(res.data); // setDispatchedOrders(res?.data?.order); // }; // const getDeliveredOrder = async () => { // let res = await axios.get(`/api/order/getAll/delivered`, { // headers: { // Authorization: `Bearer ${token}`, // }, // }); // // console.log(res.data); // setDeliveredOrders(res?.data?.order); // }; // const getCancelledOrder = async () => { // let res = await axios.get(`/api/order/getAll/cancelled`, { // headers: { // Authorization: `Bearer ${token}`, // }, // }); // // console.log(res.data); // setCancelledOrders(res?.data?.order); // }; // useEffect(() => { // getAllOrder(); // getProcessingOrder(); // getDispatchedOrder(); // getDeliveredOrder(); // getCancelledOrder(); // }, [token]); // const date = new Date(); // const day = date.getDate(); // const suffix = // day === 1 || day === 21 || day === 31 // ? "st" // : day === 2 || day === 22 // ? "nd" // : day === 3 || day === 23 // ? "rd" // : "th"; // const month = date.toLocaleDateString("en-US", { month: "long" }); // const formattedDate = `${day}${suffix} ${month}`; // // console.log(formattedDate); // const year = date.toLocaleDateString("en-US", { year: "numeric" }); // const formattedmonth = `${month} ${year}`; return ( <>

Principal Distributor

{users.length}} title="Total Principal Distributor" />

Sales Coordinator

{salescoordinator}} title="Total Sales Coordinator" />

Territory Manager

{territorymanager}} title="Total Territory Manager" /> {/* {Requests.length}} title="Contact Requests" /> */} {/* {requirement.length} } title="Requirements" /> {news.length} } title="Total News" /> {offer.length} } title="Total Offers" /> {event.length} } title="Total Events" /> */} {/* */} {/*

Products and Categories

{category.length}} title="Total Categories" /> {product.length}} title="Total products" />

Orders

{orders.length}} title="Total orders" /> {todayorders.length}} title={`Orders for ${formattedDate}`} /> {monthorders.length}} title={`Orders for ${formattedmonth}`} /> {yearorders.length}} title={`Orders for ${year}`} /> {lastyearorders.length}} title={`Orders for ${year - 1}`} /> {processingorders.length}} title="Orders - Processing" /> {dispatchedorders.length}} title="Orders - Dispatched" /> {deliveredorders.length}} title="Orders - Delivered" /> {cancelledorders.length}} title="Orders - Cancelled" /> */} ); }; export default WidgetsDropdown;