import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Link, router } from '@inertiajs/react'; import { Award, Check, Edit, Trash2 } from 'lucide-react'; import { useState } from 'react'; import CertificatePreview from './certificate-preview'; interface CertificateCardProps { type: 'course' | 'exam'; template: CertificateTemplate; } const CertificateCard = ({ type, template }: CertificateCardProps) => { const [previewTemplate, setPreviewTemplate] = useState(null); const handleActivate = (templateId: number) => { router.post( route('certificate.templates.activate', templateId), { type }, { preserveScroll: true, }, ); }; const handleDelete = (templateId: number) => { if (confirm('Are you sure you want to delete this certificate template?')) { router.delete(route('certificate.templates.destroy', templateId), { preserveScroll: true, }); } }; const handlePreview = (template: CertificateTemplate) => { setPreviewTemplate(template); }; const handleClosePreview = () => { setPreviewTemplate(null); }; return ( <> {template.is_active && (
Active
)} {template.name} Created: {new Date(template.created_at).toLocaleDateString()} {/* Mini Preview */}
handlePreview(template)} >
{template.template_data.titleText}
{template.template_data.descriptionText}
{/* Color Indicators */}
Primary
Secondary
{/* Actions */}
{!template.is_active && ( )}
{/* Preview Dialog */} {previewTemplate && ( !open && handleClosePreview()}>
Preview: {previewTemplate?.name}
)} ); }; export default CertificateCard;