import type { AICourseWithLessonCount } from '../../queries/ai-course'; import type { DifficultyLevel } from './AICourse'; import { BookOpen } from 'lucide-react'; type AICourseCardProps = { course: AICourseWithLessonCount; }; export function AICourseCard(props: AICourseCardProps) { const { course } = props; // Format date if available const formattedDate = course.createdAt ? new Date(course.createdAt).toLocaleDateString('en-US', { month: 'short', day: 'numeric', }) : null; // Map difficulty to color const difficultyColor = { beginner: 'text-green-700', intermediate: 'text-blue-700', advanced: 'text-purple-700', }[course.difficulty as DifficultyLevel] || 'text-gray-700'; // Calculate progress percentage const totalTopics = course.lessonCount || 0; const completedTopics = course.done?.length || 0; const progressPercentage = totalTopics > 0 ? Math.round((completedTopics / totalTopics) * 100) : 0; return (
{course.difficulty}

{course.title}

{totalTopics} lessons
{totalTopics > 0 && (
{progressPercentage}%
)}
); }