diff --git a/.env.development b/.env.development index 4a390ef..0a26e0e 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -VITE_API_URL=http://localhost:8088 +VITE_API_URL=http://localhost:8080 VITE_WS_URL=http://localhost:8080 -VITE_CHATBOT_URL=http://localhost:8088 -VITE_IOT_URL=http://localhost:8088 \ No newline at end of file +VITE_CHATBOT_URL=http://localhost:8080 +VITE_IOT_URL=http://localhost:8080 \ No newline at end of file diff --git a/src/components/AdminPortal/AdminDashboard.jsx b/src/components/AdminPortal/AdminDashboard.jsx index 3e199c3..67e83aa 100644 --- a/src/components/AdminPortal/AdminDashboard.jsx +++ b/src/components/AdminPortal/AdminDashboard.jsx @@ -3,7 +3,6 @@ import { useNavigate } from "react-router-dom"; import { Bell, - Settings, Activity, Users, UserCircle, @@ -23,30 +22,48 @@ function AdminDashboard() { const [hasNotification, setHasNotification] = useState(true); const navigate = useNavigate(); + const [adminData, setAdminData] = useState({ name: "", role: "" }); + + useEffect(() => { + const storedUser = localStorage.getItem("user"); + if (storedUser) { + try { + const parsed = JSON.parse(storedUser); + setAdminData({ + name: parsed.name || parsed.username || parsed.fullName || "Admin", + role: parsed.role || "Administrator", + }); + } catch (e) { + console.error("Failed to parse user from localStorage", e); + } + } + }, []); + const handleLogout = () => { - // Clear authentication data localStorage.removeItem("token"); localStorage.removeItem("user"); - - // Navigate to homepage navigate("/"); }; - const [activeTab, setActiveTab] = useState("users"); + + const [activeTab, setActiveTab] = useState("users"); const [doctorCount, setDoctorCount] = useState(0); - const [specialdoctorCount, setSpecialDoctorCount] = useState(0); + const [pendingdoctorCount, setPendingDoctorCount] = useState(0); const [patientCount, setPatientCount] = useState(0); useEffect(() => { fetch("http://localhost:8080/api/dashboard/counts") .then((res) => res.json()) .then((data) => { + console.log(data); + setDoctorCount(data.doctorCount); - setSpecialDoctorCount(data.specialdoctorCount) setPatientCount(data.patientCount); + setPendingDoctorCount(data.pendingDoctorCount); }) - .catch((error) => console.error("Error fetching dashboard counts:", error)); - }, []); - + .catch((error) => + console.error("Error fetching dashboard counts:", error) + ); +}, []); return (
@@ -75,16 +92,16 @@ function AdminDashboard() { Admin Portal

- Welcome, Section 7{" "} - Janith + Welcome,{" "} + + {adminData.name || "..."} +

{/* Right */}
- - {/* Logout */} + {/* + */} -
+ + {/* === TAB CONTENT === */}
{activeTab === "users" && } {activeTab === "accept" && } @@ -337,4 +322,4 @@ function AdminDashboard() { ); } -export default AdminDashboard; +export default AdminDashboard; \ No newline at end of file