import InputError from '@/components/input-error'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Textarea } from '@/components/ui/textarea'; import { useForm } from '@inertiajs/react'; import { Save } from 'lucide-react'; import { useState } from 'react'; import MarksheetPreview from './marksheet-preview'; const MarksheetBuilderForm = ({ template }: { template?: MarksheetTemplate | null }) => { const [logoPreview, setLogoPreview] = useState(template?.logo_path); const { data, setData, post, processing, errors } = useForm({ type: template?.type || 'course', name: template?.name || 'My Marksheet Template', logo: null as File | null, template_data: template?.template_data || { primaryColor: '#1e40af', secondaryColor: '#475569', backgroundColor: '#ffffff', borderColor: '#2563eb', headerText: 'Course Marksheet', institutionName: 'Institute Name', footerText: 'This is an official marksheet', fontFamily: 'sans-serif', }, }); const onLogoChange = (name: string, value: unknown) => { setData(name as any, value as any); setLogoPreview(URL.createObjectURL(value as File)); }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (template) { // Update existing template post(route('marksheet.templates.update', template.id)); } else { // Create new template post(route('marksheet.templates.store')); } }; return (
{/* Form Section */}
Basic Information Set the template name
{errors.type &&

{errors.type}

}
setData('name', e.target.value)} placeholder="e.g., Modern Blue Marksheet" /> {errors.name &&

{errors.name}

}
Logo & Branding Upload your institution logo
{logoPreview && (
Logo preview
)}
onLogoChange('logo', e.target.files?.[0])} />

Recommended: PNG or SVG, max 1MB

Colors Customize the marksheet color scheme
setData('template_data', { ...data.template_data, primaryColor: e.target.value })} className="h-10 w-16" /> setData('template_data', { ...data.template_data, primaryColor: e.target.value })} placeholder="#1e40af" />
setData('template_data', { ...data.template_data, secondaryColor: e.target.value })} className="h-10 w-16" /> setData('template_data', { ...data.template_data, secondaryColor: e.target.value })} placeholder="#475569" />
setData('template_data', { ...data.template_data, backgroundColor: e.target.value })} className="h-10 w-16" /> setData('template_data', { ...data.template_data, backgroundColor: e.target.value })} placeholder="#ffffff" />
setData('template_data', { ...data.template_data, borderColor: e.target.value })} className="h-10 w-16" /> setData('template_data', { ...data.template_data, borderColor: e.target.value })} placeholder="#2563eb" />
Typography Choose the font style for your marksheet
Marksheet Content Customize the text content of your marksheet
setData('template_data', { ...data.template_data, headerText: e.target.value })} placeholder="Course Marksheet" />
setData('template_data', { ...data.template_data, institutionName: e.target.value })} placeholder="Institute Name" />