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 { StudentCourseProps } from '@/types/page'; import { usePage } from '@inertiajs/react'; import { format, parseISO } from 'date-fns'; import { Award, ClipboardList, Lock } from 'lucide-react'; const CourseCertificate = () => { const { props } = usePage(); const { course, watchHistory, completion, certificateTemplate, marksheetTemplate, studentMarks, auth } = props; // Check if course is completed const isCompleted = watchHistory?.completion_date || completion?.completion === 100; if (!isCompleted) { return ( Certificate & Marksheet Locked Complete all course modules to unlock your certificate and marksheet. Your current progress: {completion?.completion || 0}% ); } const completionDate = watchHistory?.completion_date ? format(parseISO(watchHistory.completion_date), '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 course yet.

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

No Certificate Available

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

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

No Marksheet Available

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

) : ( )}
); }; export default CourseCertificate;