import React from 'react'; import { Play, BookOpen, CheckCircle2, Lock } from 'lucide-react'; import { Course } from '../types'; interface CourseCardProps { key?: string; course: Course & { progress?: number; totalLessons?: number; completedLessons?: number; isUnlocked?: boolean }; onSelect: (courseId: string) => void; onUnlockRequest?: (course: any) => void; subscriptionStatus: string; isSelected?: boolean; } export default function CourseCard({ course, onSelect, onUnlockRequest, subscriptionStatus, isSelected = false }: CourseCardProps) { const isBlocked = subscriptionStatus === 'OVERDUE' || subscriptionStatus === 'CANCELED'; const isUnlocked = course.isUnlocked !== false; // defaults to true if undefined const cardClasses = isSelected ? "absolute top-0 left-0 flex flex-row w-[380px] max-w-[90vw] h-[220px] bg-zinc-900 border-2 border-[#E50914] rounded-xl overflow-hidden cursor-pointer shadow-2xl z-20 transition-all duration-300" : "absolute top-0 left-0 w-full h-full flex flex-col bg-zinc-950/40 border border-white/10 rounded-xl overflow-hidden cursor-pointer transition-all duration-300 z-10 md:group-hover:z-30 md:group-hover:flex-row md:group-hover:scale-105 md:group-hover:w-[380px] md:group-hover:h-[220px] md:group-hover:shadow-2xl shadow-lg"; const imgContainerClasses = isSelected ? "relative w-[150px] h-full flex-shrink-0 overflow-hidden" : "relative w-full h-[180px] md:group-hover:w-[150px] md:group-hover:h-full flex-shrink-0 overflow-hidden transition-all duration-300"; const infoContainerClasses = isSelected ? "p-4 flex-grow flex flex-col justify-between min-w-0 h-full bg-zinc-900" : "p-3 flex-grow flex flex-col justify-between min-w-0 h-full bg-zinc-900/60 md:group-hover:bg-zinc-900 md:group-hover:p-4 transition-all duration-300"; return (
{ if (!isUnlocked) { if (onUnlockRequest) onUnlockRequest(course); } else { onSelect(course.id); } }} className={`relative h-[320px] w-full group ${!isUnlocked ? 'filter grayscale brightness-75 hover:brightness-100 hover:grayscale-0' : ''}`} >
{/* Thumbnail */}
{course.title} {/* Lock Overlay */} {!isUnlocked && (
Bloqueado
)} {/* Play Overlay */} {isUnlocked && (
)} {/* Progress bar at the bottom of the thumbnail */} {course.progress !== undefined && course.progress > 0 && (
)}
{/* Course Info */}
{/* Category */} {course.category} {!isUnlocked && course.price !== undefined && ( R$ {course.price.toFixed(2)} )} {/* Title */}

{course.title}

{/* Description */}

{course.description}

{/* Footer Metrics */}
{course.totalLessons || 0} Aulas
{course.progress !== undefined && course.progress > 0 ? (
{course.progress === 100 ? (
Concluído
) : ( {course.progress}% )}
) : ( {!isUnlocked && } {!isUnlocked ? 'Bloqueado' : 'Não iniciado'} )}
); }