'use client'; import { useState } from 'react'; import { useTranslations } from 'next-intl'; import { motion } from 'framer-motion'; import { MapPin, Phone, Mail, Send, Loader2, CheckCircle2 } from 'lucide-react'; import Image from 'next/image'; interface FormData { name: string; email: string; message: string; } export function ContactForm() { const t = useTranslations('pages.contact'); const [isSubmitting, setIsSubmitting] = useState(false); const [submitStatus, setSubmitStatus] = useState<'idle' | 'success' | 'error'>('idle'); const [formData, setFormData] = useState({ name: '', email: '', message: '' }); const [errors, setErrors] = useState>({}); const validateForm = () => { const newErrors: Partial = {}; if (!formData.name.trim()) { newErrors.name = t('contactForm.errors.nameRequired'); } if (!formData.email.trim()) { newErrors.email = t('contactForm.errors.emailRequired'); } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) { newErrors.email = t('contactForm.errors.emailInvalid'); } if (!formData.message.trim()) { newErrors.message = t('contactForm.errors.messageRequired'); } setErrors(newErrors); return Object.keys(newErrors).length === 0; }; const handleChange = ( e: React.ChangeEvent ) => { const { name, value } = e.target; setFormData(prev => ({ ...prev, [name]: value })); if (errors[name as keyof FormData]) { setErrors(prev => ({ ...prev, [name]: undefined })); } }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!validateForm()) return; setIsSubmitting(true); setSubmitStatus('idle'); try { // Simulate API call await new Promise(resolve => setTimeout(resolve, 1500)); setSubmitStatus('success'); setFormData({ name: '', email: '', message: '' }); } catch { setSubmitStatus('error'); } finally { setIsSubmitting(false); } }; return (
{/* Hero Section */}
{t('hero.title')} {t('hero.subtitle')}
{/* Main Content */}
{/* Contact Info */} {/* Headshot */}
Damjan Savić - Full-Stack Web Developer

{t('contactInfo.title')}

{t('contactInfo.description')}

{t('contactInfo.address.label')}

{t('contactInfo.address.value')}

{t('contactInfo.phone.label')}

{t('contactInfo.phone.value')}

{t('contactInfo.email.label')}

{t('contactInfo.email.value')}
{t('contactInfo.availabilityNote')}
{/* Contact Form */}

{t('contactForm.description')}

{errors.name && ( )}
{errors.email && ( )}