'use client' import { useState } from 'react' import { Header } from '@/components/header' import { Footer } from '@/components/footer' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Textarea } from '@/components/ui/textarea' import { Button } from '@/components/ui/button' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' import { Alert, AlertDescription } from '@/components/ui/alert' import { Mail, Phone, MapPin, Clock, Send, CheckCircle, AlertCircle } from 'lucide-react' export function ContactPageClient() { const [formData, setFormData] = useState({ name: '', email: '', company: '', service_intrest: '', message: '' }) const [errors, setErrors] = useState>({}) const [isSubmitting, setIsSubmitting] = useState(false) const [isSuccess, setIsSuccess] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setIsSubmitting(true) setErrors({}) // Client-side validation const newErrors: Record = {} if (!formData.name.trim()) newErrors.name = 'Name is required' if (!formData.email.trim()) newErrors.email = 'Email is required' if (!formData.service_intrest) newErrors.service_intrest = 'Service interest is required' if (!formData.message.trim()) newErrors.message = 'Message is required' if (Object.keys(newErrors).length > 0) { setErrors(newErrors) setIsSubmitting(false) return } try { const response = await fetch('/api/contact', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(formData), }) const result = await response.json() if (response.ok && result.success) { setIsSuccess(true) setFormData({ name: '', email: '', company: '', service_intrest: '', message: '' }) } else { if (result.errors) { setErrors(result.errors) } else { setErrors({ submit: result.message || 'Error submitting form. Please try again.' }) } } } catch (error) { setErrors({ submit: 'Network error. Please try again.' }) } finally { setIsSubmitting(false) } } const handleInputChange = (field: string, value: string) => { setFormData(prev => ({ ...prev, [field]: value })) if (errors[field]) { setErrors(prev => ({ ...prev, [field]: '' })) } } return (
{/* Page Header */}

Contact Us

Have questions about our hosting services? Get in touch with our team of experts.

{/* Contact Form */}
Send us a message {isSuccess && ( Thank you for your message! We'll get back to you soon. )} {errors.submit && ( {errors.submit} )}
handleInputChange('name', e.target.value)} className={errors.name ? 'border-red-500' : ''} /> {errors.name && (

{errors.name}

)}
handleInputChange('email', e.target.value)} className={errors.email ? 'border-red-500' : ''} /> {errors.email && (

{errors.email}

)}
handleInputChange('company', e.target.value)} />
{errors.service_intrest && (

{errors.service_intrest}

)}