Fix the dashboard

This commit is contained in:
Sibunnayak 2024-09-13 13:02:37 +05:30
parent 20e661d599
commit 5bf50ab372
3 changed files with 179 additions and 152 deletions

View File

@ -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);

View File

@ -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}
/>
</>
);

View File

@ -18,7 +18,15 @@ import axios from "axios";
{
/* <BeatLoader color="#36d7b7" /> */
}
const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistributor }) => {
const WidgetsDropdown = ({
users,
salescoordinator,
territorymanager,
retaildistributor,
Brand,
product,
category,
}) => {
// const WidgetsDropdown = ({ users, category, product, Requests }) => {
// const token = isAutheticated();
// const [orders, setOrders] = useState([]);
@ -127,7 +135,8 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistrib
// 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"
@ -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