import type { AICourseWithLessonCount } from '../../queries/ai-course'; import type { DifficultyLevel } from './AICourse'; import { BookOpen } from 'lucide-react'; import { AICourseActions } from './AICourseActions'; import { getRelativeTimeString } from '../../lib/date'; type AICourseCardProps = { course: AICourseWithLessonCount; showActions?: boolean; showProgress?: boolean; }; export function AICourseCard(props: AICourseCardProps) { const { course, showActions = true, showProgress = true } = props; const difficultyColor = { beginner: 'text-green-700', intermediate: 'text-blue-700', advanced: 'text-purple-700', }[course.difficulty as DifficultyLevel] || 'text-gray-700'; const modulesCount = course.modules?.length || 0; const totalTopics = course.lessonCount || 0; const completedTopics = course.done?.length || 0; const progressPercentage = totalTopics > 0 ? Math.round((completedTopics / totalTopics) * 100) : 0; const updatedAgo = getRelativeTimeString(course?.updatedAt); return (
); }