From f2bc8795ea05bb8c18ed62a4e0ae80e99423c14e Mon Sep 17 00:00:00 2001 From: "Mahmoud M. Abdalla" Date: Thu, 31 Jul 2025 03:12:04 +0300 Subject: [PATCH] Add debugging to dashboard cards and fix data display - Added console logging to see exact data being passed to dashboard cards - Enhanced debug section to show data types and values - Added specific debugging for SuperAdmin dashboard rendering --- frontend/src/pages/Dashboard.js | 182 ++++++++++++++++++-------------- 1 file changed, 100 insertions(+), 82 deletions(-) diff --git a/frontend/src/pages/Dashboard.js b/frontend/src/pages/Dashboard.js index 5094915..8801eae 100644 --- a/frontend/src/pages/Dashboard.js +++ b/frontend/src/pages/Dashboard.js @@ -156,104 +156,122 @@ const Dashboard = () => {

Course Stats: {JSON.stringify(courseStats)}

User Role: {user?.role}

Is Super Admin: {isSuperAdmin ? 'Yes' : 'No'}

+

Card Values:

+ ); - const renderSuperAdminDashboard = () => ( -
-
-
-
-
- + const renderSuperAdminDashboard = () => { + console.log('Rendering SuperAdmin dashboard with data:', { + userStats, + courseStats, + totalUsers: userStats?.stats?.totalUsers, + trainers: userStats?.stats?.trainers, + trainees: userStats?.stats?.trainees, + totalCourses: courseStats?.stats?.totalCourses + }); + + return ( +
+
+
+
+
+ +
+
+

Total Users

+

+ {userStats?.stats?.totalUsers || 0} +

+
-
-

Total Users

-

- {userStats?.stats?.totalUsers || 0} -

+
+ +
+
+
+ +
+
+

Trainers

+

+ {userStats?.stats?.trainers || 0} +

+
+
+
+ +
+
+
+ +
+
+

Trainees

+

+ {userStats?.stats?.trainees || 0} +

+
+
+
+ +
+
+
+ +
+
+

Total Courses

+

+ {courseStats?.stats?.totalCourses || 0} +

+
-
-
-
- -
-
-

Trainers

-

- {userStats?.stats?.trainers || 0} -

+
+
+

Recent Users

+
+ {/* Add recent users list here */} +

No recent users to display

-
+ -
-
-
- -
-
-

Trainees

-

- {userStats?.stats?.trainees || 0} -

-
-
-
- -
-
-
- -
-
-

Total Courses

-

- {courseStats?.stats?.totalCourses || 0} -

+
+

System Overview

+
+
+ Active Users + {userStats?.stats?.activeUsers || 0} +
+
+ Published Courses + {courseStats?.stats?.publishedCourses || 0} +
+
+ Total Enrollments + {enrollmentStats?.stats?.totalEnrollments || 0} +
+
+ Featured Courses + {courseStats?.stats?.featuredCourses || 0} +
- -
-
-

Recent Users

-
- {/* Add recent users list here */} -

No recent users to display

-
-
- - -
-

System Overview

-
-
- Active Users - {userStats?.stats?.activeUsers || 0} -
-
- Published Courses - {courseStats?.stats?.publishedCourses || 0} -
-
- Total Enrollments - {enrollmentStats?.stats?.totalEnrollments || 0} -
-
- Featured Courses - {courseStats?.stats?.featuredCourses || 0} -
-
-
-
-
- ); + ); + }; const renderTrainerDashboard = () => (