Fix the dashboard
This commit is contained in:
parent
20e661d599
commit
5bf50ab372
@ -28,7 +28,6 @@ const [userType, setUserType] = useState("");
|
||||
show: itemPerPage,
|
||||
},
|
||||
});
|
||||
console.log(res.data);
|
||||
setuser(res.data?.user);
|
||||
setleaveData(res.data?.leave);
|
||||
setUserType(res.data?.userType);
|
||||
|
@ -50,28 +50,38 @@ const Dashboard = () => {
|
||||
// console.log(res.data)
|
||||
setRetaildistributor(res.data.total_data);
|
||||
};
|
||||
// //2nd
|
||||
// const [category, setCategory] = useState([]);
|
||||
// const getAllCategory = async () => {
|
||||
// let res = await axios.get(`/api/category/getCategories`, {
|
||||
// headers: {
|
||||
// Authorization: `Bearer ${token}`,
|
||||
// },
|
||||
// });
|
||||
// // console.log(res.data);
|
||||
// setCategory(res?.data?.categories);
|
||||
// };
|
||||
//2nd
|
||||
const [category, setCategory] = useState(null);
|
||||
const getAllCategory = async () => {
|
||||
let res = await axios.get(`/api/category/getCategories`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
// console.log(res.data);
|
||||
setCategory(res?.data?.total_data);
|
||||
};
|
||||
// //3rd
|
||||
// const [product, setProduct] = useState([]);
|
||||
// const getAllProduct = async () => {
|
||||
// let res = await axios.get(`/api/product/getAll/user/`, {
|
||||
// headers: {
|
||||
// Authorization: `Bearer ${token}`,
|
||||
// },
|
||||
// });
|
||||
// // console.log(res.data);
|
||||
// setProduct(res?.data?.product);
|
||||
// };
|
||||
const [product, setProduct] = useState(null);
|
||||
const getAllProduct = async () => {
|
||||
let res = await axios.get(`/api/product/getAll/user/`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
// console.log(res.data);
|
||||
setProduct(res?.data?.total_data);
|
||||
};
|
||||
const [Brand, setBrand] = useState(null);
|
||||
const getAllBrands = async () => {
|
||||
let res = await axios.get(`/api/brand/getBrands`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
// console.log(res.data);
|
||||
setBrand(res?.data?.total_data);
|
||||
};
|
||||
// // 3rd
|
||||
// const [Requests, setRequests] = useState([]);
|
||||
// const getAllRequests = async () => {
|
||||
@ -152,8 +162,9 @@ const Dashboard = () => {
|
||||
getAllsalescoordinator();
|
||||
getAllterritorymanager();
|
||||
getAllretaildistributor();
|
||||
// getAllCategory();
|
||||
// getAllProduct();
|
||||
getAllCategory();
|
||||
getAllProduct();
|
||||
getAllBrands();
|
||||
// getAllRequests();
|
||||
}, [token]);
|
||||
return (
|
||||
@ -163,9 +174,9 @@ const Dashboard = () => {
|
||||
salescoordinator={salescoordinator}
|
||||
territorymanager={territorymanager}
|
||||
retaildistributor={retaildistributor}
|
||||
// category={category}
|
||||
// product={product}
|
||||
// Requests={Requests}
|
||||
category={category}
|
||||
product={product}
|
||||
Brand={Brand}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
@ -18,116 +18,125 @@ import axios from "axios";
|
||||
{
|
||||
/* <BeatLoader color="#36d7b7" /> */
|
||||
}
|
||||
const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistributor }) => {
|
||||
// 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);
|
||||
// };
|
||||
const WidgetsDropdown = ({
|
||||
users,
|
||||
salescoordinator,
|
||||
territorymanager,
|
||||
retaildistributor,
|
||||
Brand,
|
||||
product,
|
||||
category,
|
||||
}) => {
|
||||
// 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}`;
|
||||
// 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 (
|
||||
<>
|
||||
<h4>Principal Distributor</h4>
|
||||
<h4>Users</h4>
|
||||
{/* <h4>Principal Distributor</h4> */}
|
||||
<CRow>
|
||||
<CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
@ -137,9 +146,9 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
|
||||
title="Total Principal Distributor"
|
||||
/>
|
||||
</CCol>
|
||||
</CRow>
|
||||
<h4>Retail Distributor</h4>
|
||||
<CRow>
|
||||
{/* </CRow> */}
|
||||
{/* <h4>Retail Distributor</h4> */}
|
||||
{/* <CRow> */}
|
||||
<CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
className="mb-4"
|
||||
@ -148,9 +157,9 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
|
||||
title="Total Reatil Distributor"
|
||||
/>
|
||||
</CCol>
|
||||
</CRow>
|
||||
<h4>Sales Coordinator</h4>
|
||||
<CRow>
|
||||
{/* </CRow> */}
|
||||
{/* <h4>Sales Coordinator</h4> */}
|
||||
{/* <CRow> */}
|
||||
<CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
className="mb-4"
|
||||
@ -159,9 +168,9 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
|
||||
title="Total Sales Coordinator"
|
||||
/>
|
||||
</CCol>
|
||||
</CRow>
|
||||
<h4>Territory Manager</h4>
|
||||
<CRow>
|
||||
{/* </CRow> */}
|
||||
{/* <h4>Territory Manager</h4> */}
|
||||
{/* <CRow> */}
|
||||
<CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
className="mb-4"
|
||||
@ -170,8 +179,8 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
|
||||
title="Total Territory Manager"
|
||||
/>
|
||||
</CCol>
|
||||
</CRow>
|
||||
{/* <CCol sm={6} lg={3}>
|
||||
</CRow>
|
||||
{/* <CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
className="mb-4"
|
||||
color="primary"
|
||||
@ -235,14 +244,22 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
|
||||
|
||||
/> */}
|
||||
{/* </CCol> */}
|
||||
{/* </CRow>
|
||||
<h4>Products and Categories</h4>
|
||||
{/* </CRow> */}
|
||||
<h4>Products, Categories and Brands</h4>
|
||||
<CRow>
|
||||
<CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
className="mb-4"
|
||||
color="primary"
|
||||
value={<>{category.length}</>}
|
||||
value={<>{product}</>}
|
||||
title="Total products"
|
||||
/>
|
||||
</CCol>
|
||||
<CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
className="mb-4"
|
||||
color="primary"
|
||||
value={<>{category}</>}
|
||||
title="Total Categories"
|
||||
/>
|
||||
</CCol>
|
||||
@ -250,12 +267,12 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
|
||||
<CWidgetStatsA
|
||||
className="mb-4"
|
||||
color="primary"
|
||||
value={<>{product.length}</>}
|
||||
title="Total products"
|
||||
value={<>{Brand}</>}
|
||||
title="Total Brands"
|
||||
/>
|
||||
</CCol>
|
||||
</CRow>
|
||||
<h4>Orders</h4>
|
||||
{/* <h4>Orders</h4>
|
||||
<CRow>
|
||||
<CCol sm={6} lg={3}>
|
||||
<CWidgetStatsA
|
||||
@ -329,7 +346,7 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
|
||||
title="Orders - Cancelled"
|
||||
/>
|
||||
</CCol>
|
||||
</CRow>*/}
|
||||
</CRow> */}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user