Files
aplp.frontend.lms/src/components/CourseCard.jsx
T

97 lines
2.7 KiB
React
Raw Normal View History

2026-08-19 11:37:47 +07:00
import { Card, Button } from '@heroui/react';
import { PencilIcon, EllipsisVerticalIcon } from '@heroicons/react/24/outline';
const statusStyles = {
2026-08-19 21:15:42 +07:00
Active: 'bg-green-100 text-green-700',
Inactive: 'bg-gray-100 text-gray-600'
2026-08-19 11:37:47 +07:00
};
2026-08-19 21:15:42 +07:00
function CourseCard({ course, image, handleClick }) {
2026-08-19 11:37:47 +07:00
const { code, title, description, status, lastUpdate } = course;
const formattedDate = new Date(lastUpdate).toLocaleDateString('en-GB', {
day: '2-digit',
month: '2-digit',
year: 'numeric'
});
return (
<Card
variant="default"
className="w-full max-w-100 overflow-hidden rounded-lg border border-gray-300 bg-white shadow-none"
2026-08-19 21:15:42 +07:00
onClick={handleClick}
2026-08-19 11:37:47 +07:00
>
{/* Image */}
2026-08-19 21:15:42 +07:00
<div className="relative h-48 cursor-pointer overflow-hidden border-b border-gray-300">
2026-08-19 11:37:47 +07:00
<img src={image} alt={title} className="h-full w-full object-cover" />
<div className="absolute left-4 top-4 rounded-sm border border-gray-300 bg-white px-3 py-1.5">
<span className="text-lg font-semibold text-gray-800">{code}</span>
</div>
</div>
{/* Content */}
2026-08-19 21:15:42 +07:00
<Card.Content className="cursor-pointer px-5 py-5">
2026-08-19 14:26:13 +07:00
<h3 className="mb-3 text-xl font-bold leading-tight text-gray-900">
2026-08-19 11:37:47 +07:00
{title}
</h3>
2026-08-19 14:26:13 +07:00
<p className="line-clamp-2 text-md leading-8 text-gray-700">
2026-08-19 11:37:47 +07:00
{description}
</p>
</Card.Content>
{/* Footer */}
2026-08-19 21:15:42 +07:00
<Card.Footer
className="mx-5 flex items-center justify-between border-t border-gray-300 px-0 py-5"
onClick={(e) => {
e.stopPropagation();
// handle edit
}}
>
2026-08-19 11:37:47 +07:00
<div className="flex items-center gap-2">
<span
className={`rounded-full px-2.5 py-1 text-sm font-medium ${
statusStyles[status] ?? 'bg-gray-100 text-gray-600'
}`}
>
{status}
</span>
<span className="text-sm text-gray-600">Updated {formattedDate}</span>
</div>
<div className="flex items-center gap-1">
<Button
isIconOnly
variant="ghost"
size="sm"
aria-label={`Edit ${title}`}
2026-08-19 21:15:42 +07:00
onClick={(e) => {
e.stopPropagation();
// handle edit
}}
2026-08-19 11:37:47 +07:00
>
<PencilIcon className="h-5 w-5" />
</Button>
<Button
isIconOnly
variant="ghost"
size="sm"
aria-label={`More actions for ${title}`}
2026-08-19 21:15:42 +07:00
onClick={(e) => {
e.stopPropagation();
// handle edit
}}
2026-08-19 11:37:47 +07:00
>
<EllipsisVerticalIcon className="h-5 w-5" />
</Button>
</div>
</Card.Footer>
</Card>
);
}
export default CourseCard;