import DynamicCertificate from '@/components/dynamic-certificate'; import DynamicMarksheet from '@/components/dynamic-marksheet'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Card, CardContent } from '@/components/ui/card'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { StudentExamProps } from '@/types/page'; import { usePage } from '@inertiajs/react'; import { format } from 'date-fns'; import { Award, ClipboardList, Lock } from 'lucide-react'; const ExamCertificate = () => { const { props } = usePage(); const { exam, bestAttempt, certificateTemplate, marksheetTemplate, studentMarks, auth } = props; // Check if exam is passed const isPassed = bestAttempt?.is_passed || false; const hasCompletedAttempt = bestAttempt?.status === 'completed'; if (!hasCompletedAttempt) { return ( Certificate & Marksheet Locked Complete at least one exam attempt to unlock your certificate and marksheet. ); } if (!isPassed) { return ( Certificate & Marksheet Locked You need to pass the exam to unlock your certificate and marksheet. ); } const completionDate = bestAttempt?.end_time ? format(new Date(bestAttempt.end_time), 'MMMM d, yyyy') : format(new Date(), 'MMMM d, yyyy'); // Check if both are unavailable if (!certificateTemplate && !marksheetTemplate) { return (

No Certificate or Marksheet Available

The instructor hasn't set up certificates or marksheets for this exam yet.

); } return (
Certificate Marksheet {!certificateTemplate ? (

No Certificate Available

The instructor hasn't set up certificates for this exam yet.

) : ( )}
{!marksheetTemplate || !studentMarks ? (

No Marksheet Available

{!marksheetTemplate ? "The instructor hasn't set up marksheets for this exam yet." : 'No marks data available. Complete exam attempts to view your marksheet.'}

) : ( )}
); }; export default ExamCertificate;