From 59eedaf102664c36ee59b51013276b6b47665acc Mon Sep 17 00:00:00 2001 From: ROSHAN GARG Date: Fri, 18 Oct 2024 16:20:10 +0530 Subject: [PATCH] dashboard api done --- src/axios.js | 4 ++-- src/views/dashboard/Dashboard.js | 36 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/axios.js b/src/axios.js index caa51e0..7a8940a 100644 --- a/src/axios.js +++ b/src/axios.js @@ -1,11 +1,11 @@ import axios from 'axios' const Axios = axios.create({ - // baseURL: 'http://localhost:5000/', + baseURL: 'http://localhost:5000/', // baseURL: 'https://leadesh-whatsapp.onrender.com', // baseURL: "https://api.leadesh.com/", // baseURL: 'https://cheminova-api-2.onrender.com', // latest is this one - baseURL: 'https://api.cnapp.co.in', // latest is this one + // baseURL: 'https://api.cnapp.co.in', // latest is this one }) export default Axios diff --git a/src/views/dashboard/Dashboard.js b/src/views/dashboard/Dashboard.js index fa9b060..9b9b3bc 100644 --- a/src/views/dashboard/Dashboard.js +++ b/src/views/dashboard/Dashboard.js @@ -17,24 +17,23 @@ const Dashboard = () => { }) const token = isAutheticated() // Fetch counts on component mount - // useEffect(() => { - // const getCounts = async () => { - // try { - // const res = await Axios.get('/api/get-counts-pdOrders', { - // headers: { - // Authorization: `Bearer ${token}`, - // }, - // }) // Updated API endpoint - // if (res.status === 200) { - // console.log('res', res) - // setCounts(res.data.counts) // Assuming the response is in the format { new, dispatched, cancelled, processing, delivered } - // } - // } catch (error) { - // console.error('Failed to fetch status counts:', error) - // } - // } - // getCounts() - // }, []) + useEffect(() => { + const getCounts = async () => { + try { + const res = await Axios.get('/api/get-counts-rdOrders', { + headers: { + Authorization: `Bearer ${token}`, + }, + }) // Updated API endpoint + if (res.status === 200) { + setCounts(res.data.counts) // Assuming the response is in the format { new, dispatched, cancelled, processing, delivered } + } + } catch (error) { + console.error('Failed to fetch status counts:', error) + } + } + getCounts() + }, []) // Define colors for different statuses const statusColors = { @@ -43,6 +42,7 @@ const Dashboard = () => { cancelled: '#f44336', // Red processing: '#ff9800', // Orange delivered: '#9c27b0', // Purple + pending: '#56F000 ', } const statusIcons = { new: ,