cryogenic22 commited on
Commit
7dd2ba3
·
verified ·
1 Parent(s): b68556c

Create learning-paths/PathCard.tsx

Browse files
frontend/src/components/learning-paths/PathCard.tsx ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/components/learning-paths/PathCard.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 { useLearning } from '../../contexts/LearningContext';
6
+ import { useUser } from '../../contexts/UserContext';
7
+
8
+ const PathCard = ({ path }) => {
9
+ const { setCurrentPath } = useLearning();
10
+ const { user } = useUser();
11
+
12
+ const completedModules = path.modules.filter(module =>
13
+ user.progress.completedModules.includes(module.id)
14
+ ).length;
15
+
16
+ const progress = (completedModules / path.modules.length) * 100;
17
+
18
+ return (
19
+ <Card className="hover:shadow-lg transition-shadow duration-300">
20
+ <CardHeader>
21
+ <CardTitle>{path.name}</CardTitle>
22
+ </CardHeader>
23
+ <CardContent>
24
+ <p className="text-gray-600 mb-4">{path.description}</p>
25
+ <div className="space-y-4">
26
+ <div className="flex justify-between text-sm text-gray-600">
27
+ <span>{completedModules} / {path.modules.length} modules</span>
28
+ <span>{Math.round(progress)}% complete</span>
29
+ </div>
30
+ <Progress value={progress} className="h-2" />
31
+ <button
32
+ onClick={() => setCurrentPath(path.id)}
33
+ className="w-full bg-blue-500 text-white p-2 rounded hover:bg-blue-600
34
+ transition-colors duration-300"
35
+ >
36
+ Continue Learning
37
+ </button>
38
+ </div>
39
+ </CardContent>
40
+ </Card>
41
+ );
42
+ };
43
+
44
+ export default PathCard;