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 { Check, ClipboardList, Edit, Trash2 } from 'lucide-react'; import { useState } from 'react'; import MarksheetPreview from './marksheet-preview'; interface MarkSheetCardProps { type: 'course' | 'exam'; template: MarksheetTemplate; } const MarkSheetCard = ({ type, template }: MarkSheetCardProps) => { const [previewMarksheet, setPreviewMarksheet] = useState(null); const handleMarksheetActivate = (templateId: number) => { router.post( route('marksheet.templates.activate', templateId), { type }, { preserveScroll: true, }, ); }; const handleMarksheetDelete = (templateId: number) => { if (confirm('Are you sure you want to delete this marksheet template?')) { router.delete(route('marksheet.templates.destroy', templateId), { preserveScroll: true, }); } }; const handleMarksheetPreview = (template: MarksheetTemplate) => { setPreviewMarksheet(template); }; const handleCloseMarksheetPreview = () => { setPreviewMarksheet(null); }; return ( <> {template.is_active && (
Active
)} {template.name} Created: {new Date(template.created_at).toLocaleDateString()} {/* Mini Preview */}
handleMarksheetPreview(template)} >
{template.template_data.headerText}
{template.template_data.institutionName}
{/* Color Indicators */}
Primary
Secondary
{/* Actions */}
{!template.is_active && ( )}
{/* Marksheet Preview Dialog */} {previewMarksheet && ( !open && handleCloseMarksheetPreview()}>
Preview: {previewMarksheet?.name}
)} ); }; export default MarkSheetCard;