Spaces:
Build error
Build error
Create frontend/src/components/learning-paths/ModuleList.tsx
Browse files
frontend/src/components/learning-paths/ModuleList.tsx
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// src/components/learning-paths/ModuleList.tsx
|
| 2 |
+
import React from 'react';
|
| 3 |
+
import { Card, CardContent } from '@/components/ui/card';
|
| 4 |
+
import { useUser } from '../../contexts/UserContext';
|
| 5 |
+
|
| 6 |
+
const ModuleList = ({ modules }) => {
|
| 7 |
+
const { user, updateProgress } = useUser();
|
| 8 |
+
|
| 9 |
+
return (
|
| 10 |
+
<div className="space-y-4">
|
| 11 |
+
{modules.map((module) => {
|
| 12 |
+
const isCompleted = user.progress.completedModules.includes(module.id);
|
| 13 |
+
|
| 14 |
+
return (
|
| 15 |
+
<Card key={module.id} className="relative">
|
| 16 |
+
<CardContent className="p-4">
|
| 17 |
+
<div className="flex items-center gap-4">
|
| 18 |
+
<div className={`w-8 h-8 rounded-full flex items-center justify-center
|
| 19 |
+
${isCompleted ? 'bg-green-500' : 'bg-gray-200'}`}>
|
| 20 |
+
{isCompleted ? '✓' : module.order}
|
| 21 |
+
</div>
|
| 22 |
+
<div className="flex-1">
|
| 23 |
+
<h3 className="font-semibold">{module.name}</h3>
|
| 24 |
+
<p className="text-sm text-gray-600">{module.description}</p>
|
| 25 |
+
</div>
|
| 26 |
+
<button
|
| 27 |
+
onClick={() => updateProgress(module.id)}
|
| 28 |
+
disabled={isCompleted}
|
| 29 |
+
className={`px-4 py-2 rounded ${
|
| 30 |
+
isCompleted
|
| 31 |
+
? 'bg-gray-200 text-gray-600'
|
| 32 |
+
: 'bg-blue-500 text-white hover:bg-blue-600'
|
| 33 |
+
}`}
|
| 34 |
+
>
|
| 35 |
+
{isCompleted ? 'Completed' : 'Start'}
|
| 36 |
+
</button>
|
| 37 |
+
</div>
|
| 38 |
+
</CardContent>
|
| 39 |
+
</Card>
|
| 40 |
+
);
|
| 41 |
+
})}
|
| 42 |
+
</div>
|
| 43 |
+
);
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
export default ModuleList;
|