diff --git a/backend/routes/courses.js b/backend/routes/courses.js index 9a45e37..ab19f29 100644 --- a/backend/routes/courses.js +++ b/backend/routes/courses.js @@ -458,6 +458,8 @@ router.get('/trainers/available', auth, requireSuperAdmin, async (req, res) => { // @access Private router.get('/stats/overview', auth, async (req, res) => { try { + console.log('Course stats endpoint called by user:', req.user.id, req.user.role); + const whereClause = {}; if (req.user.role === 'trainer') { whereClause.trainerId = req.user.id; @@ -471,6 +473,8 @@ router.get('/stats/overview', auth, async (req, res) => { where: { ...whereClause, isFeatured: true } }); + console.log('Course stats calculated:', { totalCourses, publishedCourses, featuredCourses, whereClause }); + // For trainers, provide specific stats let myCourses = 0; let myPublishedCourses = 0; diff --git a/backend/routes/users.js b/backend/routes/users.js index b81a6b5..9b087ca 100644 --- a/backend/routes/users.js +++ b/backend/routes/users.js @@ -219,11 +219,15 @@ router.delete('/:id', auth, requireSuperAdmin, async (req, res) => { // @access Private (Super Admin) router.get('/stats/overview', auth, requireSuperAdmin, async (req, res) => { try { + console.log('User stats endpoint called by user:', req.user.id, req.user.role); + const totalUsers = await User.count(); const activeUsers = await User.count({ where: { isActive: true } }); const trainers = await User.count({ where: { role: 'trainer' } }); const trainees = await User.count({ where: { role: 'trainee' } }); + console.log('User stats calculated:', { totalUsers, activeUsers, trainers, trainees }); + res.json({ stats: { totalUsers, diff --git a/frontend/src/components/Layout.js b/frontend/src/components/Layout.js index d182e77..e786fd3 100644 --- a/frontend/src/components/Layout.js +++ b/frontend/src/components/Layout.js @@ -55,41 +55,41 @@ const Layout = () => {
-
User Stats: {JSON.stringify(userStats)}
+Course Stats: {JSON.stringify(courseStats)}
+User Role: {user?.role}
+Is Super Admin: {isSuperAdmin ? 'Yes' : 'No'}
+Welcome back, {user?.firstName}! Here's what's happening.