import { useState } from 'react'
import { motion } from 'framer-motion'
import { FaEnvelope, FaMapMarkerAlt } from 'react-icons/fa'
import { useNotification } from '../context/notification-context'
const Contact = () => {
const { showNotification } = useNotification()
const [isSubmitting, setIsSubmitting] = useState(false)
const [formData, setFormData] = useState({
name: '',
email: '',
message: '',
website: '' // Honeypot field
})
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
if (isSubmitting) return
setIsSubmitting(true)
try {
const response = await fetch('/api/contact', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData),
})
const data = await response.json()
if (data.success) {
showNotification('Message sent successfully!', 'success')
setFormData({ name: '', email: '', message: '', website: '' })
} else {
showNotification(data.message || 'Failed to send message', 'error')
}
} catch (error) {
const errorMessage = error instanceof Error ? error.message : 'An error occurred. Please try again later.'
showNotification(errorMessage, 'error')
} finally {
setTimeout(() => {
setIsSubmitting(false)
}, 1000)
}
}
const contactInfo = [
{
icon:
We're here to help and answer any questions you might have
{info.content}