Spaces:
Build error
Build error
Create frontend/src/components/learning-paths/ProgressTracker.tsx
Browse files
frontend/src/components/learning-paths/ProgressTracker.tsx
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// src/components/learning-paths/ProgressTracker.tsx
|
| 2 |
+
import React from 'react';
|
| 3 |
+
import { Card, CardHeader, CardContent, CardTitle } from '@/components/ui/card';
|
| 4 |
+
import { Progress } from '@/components/ui/progress';
|
| 5 |
+
import { useUser } from '../../contexts/UserContext';
|
| 6 |
+
import { useLearning } from '../../contexts/LearningContext';
|
| 7 |
+
|
| 8 |
+
const ProgressTracker = () => {
|
| 9 |
+
const { user } = useUser();
|
| 10 |
+
const { paths } = useLearning();
|
| 11 |
+
|
| 12 |
+
const totalModules = paths.reduce((acc, path) =>
|
| 13 |
+
acc + path.modules.length, 0
|
| 14 |
+
);
|
| 15 |
+
|
| 16 |
+
const completedModules = user.progress.completedModules.length;
|
| 17 |
+
const overallProgress = (completedModules / totalModules) * 100;
|
| 18 |
+
|
| 19 |
+
return (
|
| 20 |
+
<Card>
|
| 21 |
+
<CardHeader>
|
| 22 |
+
<CardTitle>Learning Progress</CardTitle>
|
| 23 |
+
</CardHeader>
|
| 24 |
+
<CardContent>
|
| 25 |
+
<div className="space-y-6">
|
| 26 |
+
<div>
|
| 27 |
+
<div className="flex justify-between text-sm text-gray-600 mb-2">
|
| 28 |
+
<span>Overall Progress</span>
|
| 29 |
+
<span>{Math.round(overallProgress)}%</span>
|
| 30 |
+
</div>
|
| 31 |
+
<Progress value={overallProgress} className="h-2" />
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<div className="grid grid-cols-2 gap-4">
|
| 35 |
+
<div className="bg-blue-50 p-4 rounded">
|
| 36 |
+
<div className="text-2xl font-bold text-blue-600">
|
| 37 |
+
{completedModules}
|
| 38 |
+
</div>
|
| 39 |
+
<div className="text-sm text-gray-600">Modules Completed</div>
|
| 40 |
+
</div>
|
| 41 |
+
<div className="bg-green-50 p-4 rounded">
|
| 42 |
+
<div className="text-2xl font-bold text-green-600">
|
| 43 |
+
{user.progress.learningStreak}
|
| 44 |
+
</div>
|
| 45 |
+
<div className="text-sm text-gray-600">Day Streak</div>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
|
| 49 |
+
{user.progress.achievements.length > 0 && (
|
| 50 |
+
<div>
|
| 51 |
+
<h3 className="font-semibold mb-2">Recent Achievements</h3>
|
| 52 |
+
<div className="space-y-2">
|
| 53 |
+
{user.progress.achievements.slice(-3).map((achievement, idx) => (
|
| 54 |
+
<div key={idx} className="flex items-center gap-2 text-sm">
|
| 55 |
+
<span>🏆</span>
|
| 56 |
+
<span>{achievement.name}</span>
|
| 57 |
+
<span className="text-gray-500">
|
| 58 |
+
{new Date(achievement.date).toLocaleDateString()}
|
| 59 |
+
</span>
|
| 60 |
+
</div>
|
| 61 |
+
))}
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
)}
|
| 65 |
+
</div>
|
| 66 |
+
</CardContent>
|
| 67 |
+
</Card>
|
| 68 |
+
);
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
export default ProgressTracker;
|