File size: 884 Bytes
1906404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { getDashboardStats, getAllUserProgress } from '../services/firebaseService.js';

/**
 * GET /api/dashboard
 * Returns aggregated stats for the authenticated user's dashboard.
 */
export async function getDashboard(req, res) {
  try {
    const stats = await getDashboardStats(req.user.uid);

    // Calculate total pending (we need the full company data count)
    // For now, just return totalSolved; client can compute pending from local data
    res.json({
      totalInterviews: stats.totalInterviews,
      avgScore: stats.avgScore,
      recentInterviews: stats.recentInterviews,
      latestATSScore: stats.latestATSScore,
      latestATSSuggestions: stats.latestATSSuggestions,
      totalSolved: stats.totalSolved,
    });
  } catch (error) {
    console.error('Dashboard error:', error);
    res.status(500).json({ error: 'Failed to fetch dashboard data.' });
  }
}