import { Button } from '@/components/ui/button'; import { Card, CardContent, CardFooter, CardHeader } from '@/components/ui/card'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; import { cn, getCourseDuration, systemCurrency } from '@/lib/utils'; import { SharedData } from '@/types/global'; import { Link, router, usePage } from '@inertiajs/react'; import { Clock, Heart, Star, Users } from 'lucide-react'; interface Props { course: Course; viewType?: 'grid' | 'list'; className?: string; wishlists?: CourseWishlist[]; } const CourseCard1 = ({ course, viewType = 'grid', className, wishlists }: Props) => { const { props } = usePage(); const { user } = props.auth; const { translate } = props; const { button, frontend, common } = translate; const isWishlisted = wishlists?.find((wishlist) => wishlist.course_id === course.id); const currency = systemCurrency(props.system.fields['selling_currency']); const handleWishlist = () => { if (isWishlisted) { router.delete(route('course-wishlists.destroy', { id: isWishlisted.id })); } else { router.post(route('course-wishlists.store', { user_id: user?.id, course_id: course.id })); } }; return (
{course.title} { const target = e.target as HTMLImageElement; target.src = '/assets/images/blank-image.jpg'; }} />
{wishlists && (

{isWishlisted ? frontend.remove_from_wishlist : frontend.add_to_wishlist}

)}
{course.enrollments_count || 0} {course.enrollments_count || 0 > 0 ? ` ${common.students}` : ` ${frontend.student}`} {getCourseDuration(course, 'readable')}

{course.title}

{course.average_rating ? Number(course.average_rating).toFixed(2) : '0.00'} ({course.reviews_count || 0} {common.reviews})

{course.pricing_type === 'free' ? ( common.free ) : course.discount ? ( <> {currency?.symbol} {course.discount_price} {currency?.symbol} {course.price} ) : ( <> {currency?.symbol} {course.price} )}

); }; export default CourseCard1;