File size: 1,539 Bytes
7dd2ba3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// src/components/learning-paths/PathCard.tsx
import React from 'react';
import { Card, CardHeader, CardContent, CardTitle } from '@/components/ui/card';
import { Progress } from '@/components/ui/progress';
import { useLearning } from '../../contexts/LearningContext';
import { useUser } from '../../contexts/UserContext';

const PathCard = ({ path }) => {
  const { setCurrentPath } = useLearning();
  const { user } = useUser();

  const completedModules = path.modules.filter(module => 
    user.progress.completedModules.includes(module.id)
  ).length;

  const progress = (completedModules / path.modules.length) * 100;

  return (
    <Card className="hover:shadow-lg transition-shadow duration-300">
      <CardHeader>
        <CardTitle>{path.name}</CardTitle>
      </CardHeader>
      <CardContent>
        <p className="text-gray-600 mb-4">{path.description}</p>
        <div className="space-y-4">
          <div className="flex justify-between text-sm text-gray-600">
            <span>{completedModules} / {path.modules.length} modules</span>
            <span>{Math.round(progress)}% complete</span>
          </div>
          <Progress value={progress} className="h-2" />
          <button
            onClick={() => setCurrentPath(path.id)}
            className="w-full bg-blue-500 text-white p-2 rounded hover:bg-blue-600 
                     transition-colors duration-300"
          >
            Continue Learning
          </button>
        </div>
      </CardContent>
    </Card>
  );
};

export default PathCard;