import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Helmet } from 'react-helmet-async'; import { Mail, Send, CheckCircle, AlertCircle, Loader2, Phone, MapPin, ChevronDown, Github, Twitter, Linkedin, Facebook, Instagram, } from 'lucide-react'; import { isAxiosError } from 'axios'; import { toast } from 'sonner'; import SEOHead from '@/components/seo/SEOHead'; import { generateWebPage, getSiteOrigin } from '@/utils/seo'; import { getApiClient } from '@/services/api'; const CONTACT_EMAIL = 'support@dociva.io'; const CONTACT_PHONE = '+1 (555) 123-4567'; const OFFICE_ADDRESS = '123 Tech Avenue, Innovation City, CA 90001'; const API_BASE = import.meta.env.VITE_API_URL || ''; const api = getApiClient(); type Category = 'general' | 'bug' | 'feature'; const FAQ_ITEMS = [ { questionKey: 'pages.contact.faq1q', answerKey: 'pages.contact.faq1a', questionDefault: 'What is your pricing?', answerDefault: 'We offer a generous free tier with all tools. Pro plans start at $9/month for more credits and features.' }, { questionKey: 'pages.contact.faq2q', answerKey: 'pages.contact.faq2a', questionDefault: 'How does the platform work?', answerDefault: 'Upload your file, choose a tool, and download the result — no sign-up required for basic usage.' }, { questionKey: 'pages.contact.faq3q', answerKey: 'pages.contact.faq3a', questionDefault: 'Is my data secure?', answerDefault: 'Yes. All transfers are encrypted, and files are automatically deleted within minutes of processing.' }, ]; const SOCIAL_LINKS = [ { icon: Facebook, href: '#', label: 'Facebook' }, { icon: Twitter, href: '#', label: 'Twitter' }, { icon: Linkedin, href: '#', label: 'LinkedIn' }, { icon: Instagram, href: '#', label: 'Instagram' }, { icon: Github, href: '#', label: 'GitHub' }, ]; export default function ContactPage() { const { t } = useTranslation(); const siteOrigin = getSiteOrigin(typeof window !== 'undefined' ? window.location.origin : ''); const [category, setCategory] = useState('general'); const [submitted, setSubmitted] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [openFaq, setOpenFaq] = useState(null); const placeholderKey = `pages.contact.${category}Placeholder` as const; async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(''); setLoading(true); const form = e.currentTarget; const data = new FormData(form); try { await api.post(`${API_BASE}/contact/submit`, { name: data.get('name'), email: data.get('email'), category, subject: data.get('subject'), message: data.get('message'), }); setSubmitted(true); toast.success(t('pages.contact.successMessage')); } catch (err: unknown) { let errMsg = ''; if (isAxiosError(err) && err.response?.data?.error) { errMsg = err.response.data.error; } else if (err instanceof Error) { errMsg = err.message; } else { errMsg = String(err); } setError(errMsg); toast.error(errMsg); } finally { setLoading(false); } } if (submitted) { return ( <> {t('pages.contact.title')} — {t('common.appName')}

{t('pages.contact.successMessage')}

); } return ( <>
{/* Page header */}

{t('pages.contact.title', 'Get in Touch')}

{t('pages.contact.subtitle')}

{/* Two-column layout */}
{/* Left column — Contact form */}
{/* Category */} {/* Name */} {/* Email */} {/* Subject */} {/* Message */}