import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Label } from '@/components/ui/label'; import { Switch } from '@/components/ui/switch'; import DashboardLayout from '@/layouts/dashboard/layout'; import { SharedData } from '@/types/global'; import { Head, Link, router } from '@inertiajs/react'; import { Award, Plus } from 'lucide-react'; import { useEffect, useState } from 'react'; import CertificateCard from './partials/certificate-card'; interface CertificatePageProps extends SharedData { templates: CertificateTemplate[]; } const CertificateIndex = ({ templates, system }: CertificatePageProps) => { const examTemplates = templates.filter((template) => template.type === 'exam'); const courseTemplates = templates.filter((template) => template.type === 'course'); const initialCourseCertificateEnabled = system?.fields?.show_course_certificate ?? true; const [courseCertificateEnabled, setCourseCertificateEnabled] = useState(initialCourseCertificateEnabled); useEffect(() => { setCourseCertificateEnabled(initialCourseCertificateEnabled); }, [initialCourseCertificateEnabled]); const handleCourseCertificateToggle = (checked: boolean) => { const previous = courseCertificateEnabled; setCourseCertificateEnabled(checked); router.post( route('certification.settings.update'), { show_course_certificate: checked }, { preserveScroll: true, preserveState: true, onError: () => setCourseCertificateEnabled(previous) }, ); }; return ( <>

Enable/disable course certificates for students.

Certificate Templates

Manage your certificate templates for course completion

Course Certificate Templates
{courseTemplates.length === 0 ? (

No certificate templates yet

Create your first certificate template to get started

) : (
{courseTemplates.map((template) => ( ))}
)}
Exam Certificate Templates
{examTemplates.length === 0 ? (

No certificate templates yet

Create your first certificate template to get started

) : (
{examTemplates.map((template) => ( ))}
)}
); }; CertificateIndex.layout = (page: React.ReactNode) => ; export default CertificateIndex;