From b95e4a9b3d0f1451e44f804a57cb58c14387807d Mon Sep 17 00:00:00 2001
From: Irozuku
Date: Thu, 12 Mar 2026 17:08:20 -0300
Subject: [PATCH] refactor(contact): remove handleSubmit and update form action
to FormSubmit
---
components/contact-section.tsx | 48 +++-------------------------------
1 file changed, 3 insertions(+), 45 deletions(-)
diff --git a/components/contact-section.tsx b/components/contact-section.tsx
index 4bce56c..3307fb5 100644
--- a/components/contact-section.tsx
+++ b/components/contact-section.tsx
@@ -11,50 +11,6 @@ export function ContactSection() {
})
const [status, setStatus] = useState<'idle' | 'sending' | 'success' | 'error'>('idle')
- const handleSubmit = async (e: React.FormEvent) => {
- e.preventDefault()
- setStatus('sending')
-
- try {
- const formPayload = {
- name: formData.name,
- email: formData.email,
- message: formData.message,
- _subject: `Nuevo mensaje de contacto de DashAI - ${formData.name}`,
- }
-
- console.log('Sending form data:', formPayload)
-
- const response = await fetch(`https://formspree.io/f/mnnwakle`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'Accept': 'application/json',
- },
- body: JSON.stringify(formPayload),
- })
-
- const responseData = await response.json()
- console.log('Formspree response:', response.status, responseData)
-
- if (response.ok) {
- setStatus('success')
- setFormData({ name: '', email: '', message: '' })
- setTimeout(() => setStatus('idle'), 5000)
- } else {
- // Mostrar error más específico
- const errorMessage = responseData.error || responseData.message || 'Error al enviar el mensaje'
- console.error('Formspree error:', responseData)
- setStatus('error')
- setTimeout(() => setStatus('idle'), 5000)
- }
- } catch (error) {
- console.error('Form submission error:', error)
- setStatus('error')
- setTimeout(() => setStatus('idle'), 3000)
- }
- }
-
const handleChange = (e: React.ChangeEvent) => {
setFormData(prev => ({
...prev,
@@ -74,7 +30,7 @@ export function ContactSection() {
-