|
1 | 1 | import React, { useEffect, useState } from 'react'; |
2 | 2 | import { useAuth } from '../../context/AuthContext'; |
3 | 3 | import { Flame, Trophy, CheckCircle, BookOpen, Star } from 'lucide-react'; |
4 | | - |
| 4 | +import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts'; |
5 | 5 | interface UserStats { |
6 | 6 | streak: number; |
7 | 7 | total_solved: number; |
@@ -50,8 +50,19 @@ export const ProgressDashboard: React.FC = () => { |
50 | 50 |
|
51 | 51 | if (!stats) return <div style={{ padding: '2rem', textAlign: 'center' }}>Loading dashboard...</div>; |
52 | 52 |
|
| 53 | + const chartData = Array.from({ length: 14 }).map((_, i) => { |
| 54 | + const d = new Date(); |
| 55 | + d.setDate(d.getDate() - (13 - i)); |
| 56 | + const dateStr = d.toISOString().split('T')[0]; |
| 57 | + const shortDate = d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); |
| 58 | + return { |
| 59 | + date: shortDate, |
| 60 | + solved: stats.activity_map[dateStr] || 0 |
| 61 | + }; |
| 62 | + }); |
| 63 | + |
53 | 64 | return ( |
54 | | - <div className="main-content" style={{ padding: '2rem', maxWidth: '900px', margin: '0 auto', width: '100%' }}> |
| 65 | + <div className="main-content" style={{ padding: '2rem', maxWidth: '1200px', margin: '0 auto', width: '100%' }}> |
55 | 66 | <h2 style={{ marginBottom: '2rem' }}>Learning Progress</h2> |
56 | 67 |
|
57 | 68 | <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '1.5rem', marginBottom: '2rem' }}> |
@@ -131,6 +142,24 @@ export const ProgressDashboard: React.FC = () => { |
131 | 142 | </ul> |
132 | 143 | </div> |
133 | 144 | </div> |
| 145 | + |
| 146 | + <div className="glass" style={{ padding: '1.5rem', marginTop: '1.5rem' }}> |
| 147 | + <h3 style={{ marginBottom: '1.5rem' }}>Problems Solved (Last 14 Days)</h3> |
| 148 | + <div style={{ width: '100%', height: 300 }}> |
| 149 | + <ResponsiveContainer width="100%" height="100%"> |
| 150 | + <LineChart data={chartData} margin={{ top: 5, right: 20, bottom: 5, left: 0 }}> |
| 151 | + <CartesianGrid strokeDasharray="3 3" stroke="rgba(255,255,255,0.1)" /> |
| 152 | + <XAxis dataKey="date" stroke="rgba(255,255,255,0.5)" /> |
| 153 | + <YAxis stroke="rgba(255,255,255,0.5)" allowDecimals={false} /> |
| 154 | + <Tooltip |
| 155 | + contentStyle={{ backgroundColor: 'hsl(var(--bg-primary))', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '8px' }} |
| 156 | + itemStyle={{ color: 'hsl(var(--accent-primary))' }} |
| 157 | + /> |
| 158 | + <Line type="monotone" dataKey="solved" name="Questions Solved" stroke="hsl(var(--accent-primary))" strokeWidth={3} dot={{ r: 4, fill: 'hsl(var(--accent-primary))' }} activeDot={{ r: 8 }} /> |
| 159 | + </LineChart> |
| 160 | + </ResponsiveContainer> |
| 161 | + </div> |
| 162 | + </div> |
134 | 163 | </div> |
135 | 164 | ); |
136 | 165 | }; |
0 commit comments