'use client' import { useState } from 'react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Textarea } from '@/components/ui/textarea' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' import { Send } from 'lucide-react' import { toast } from 'sonner' interface ContactFormProps { className?: string variant?: 'default' | 'minimal' | 'professional' onSubmitSuccess?: () => void showInquiryType?: boolean title?: string description?: string } export default function ContactForm({}: ContactFormProps) { const [formData, setFormData] = useState({ name: '', email: '', subject: '', message: '', inquiry_type: '' }) const [isSubmitting, setIsSubmitting] = useState(false) const handleInputChange = (e: React.ChangeEvent) => { const { name, value } = e.target setFormData(prev => ({ ...prev, [name]: value })) } const handleSelectChange = (value: string) => { setFormData(prev => ({ ...prev, inquiry_type: value })) } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setIsSubmitting(true) try { const response = await fetch('/api/forms', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ formId: 'contact', // Add formId for the simplified schema name: formData.name, email: formData.email, subject: formData.subject, message: formData.message, inquiryType: formData.inquiry_type, formSource: 'contact-page' }) }) const result = await response.json() if (result.success) { toast.success('Message sent successfully! We\'ll get back to you soon.') setFormData({ name: '', email: '', subject: '', message: '', inquiry_type: '' }) } else { throw new Error(result.message || 'Failed to send message') } } catch (error) { console.error('Form submission error:', error) toast.error('Failed to send message. Please try again.') } finally { setIsSubmitting(false) } } return (
{/* Name & Email Row */}
{/* Inquiry Type */}
{/* Subject */}
{/* Message */}