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 CertificatePreview from './certificate-preview'; const CertificateBuilderForm = ({ template }: { template?: CertificateTemplate | null }) => { const [logoPreview, setLogoPreview] = useState(template?.logo_path); const { data, setData, post, processing, errors } = useForm({ type: template?.type || 'course', name: template?.name || 'My Certificate Template', logo: null as File | null, template_data: template?.template_data || { primaryColor: '#3730a3', secondaryColor: '#4b5563', backgroundColor: '#dbeafe', borderColor: '#f59e0b', titleText: 'Certificate of Completion', descriptionText: 'This certificate is proudly presented to', completionText: 'for successfully completing the course', footerText: 'Authorized Certificate', fontFamily: '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('certificate.templates.update', template.id)); } else { // Create new template post(route('certificate.templates.store')); } }; return (
{errors.type}
}{errors.name}
}Recommended: PNG or SVG, max 1MB