import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'; import { StudentExamProps } from '@/types/page'; import { usePage } from '@inertiajs/react'; import { format } from 'date-fns'; import { Download, ExternalLink } from 'lucide-react'; const ExamResources = () => { const { exam } = usePage().props; // Function to format date in Bengali style if needed const formatDate = (dateString: string) => { const date = new Date(dateString); return format(date, 'MMMM dd, yyyy, hh:mm a'); }; // Helper to handle file download const handleDownload = async (resource: ExamResource, e: React.MouseEvent) => { e.preventDefault(); try { // For non-link resources, use the download endpoint const url = route('exam-resources.download', resource.id); window.open(url, '_blank'); } catch (error) { // Fallback to direct download if the endpoint fails window.open(resource.resource, '_blank'); } }; return (
{exam.resources.length > 0 ? (

Exam Resources

Title Date & Time Action {exam.resources.map((resource, index) => ( {resource.title} {formatDate(resource.created_at)}
{resource.type === 'link' ? ( ) : ( )}
))}
) : (

No resources available for this exam yet.

)}
); }; export default ExamResources;