From b9fca68b300c7c0008140774f8a8a8c34b4747e4 Mon Sep 17 00:00:00 2001 From: gitea Date: Wed, 19 Nov 2025 23:48:28 +0100 Subject: [PATCH] formspree fix --- app/feedback/page.tsx | 196 ++++++++++++++++++++++++++++++----------- components/Contact.tsx | 196 ++++++++++++++++++++++++++++++----------- 2 files changed, 286 insertions(+), 106 deletions(-) diff --git a/app/feedback/page.tsx b/app/feedback/page.tsx index 5347e09..5a0a58a 100644 --- a/app/feedback/page.tsx +++ b/app/feedback/page.tsx @@ -21,12 +21,12 @@ export default function FeedbackPage() { setErrorMessage(''); const form = e.currentTarget; - const data = new FormData(form); + const formDataObj = new FormData(form); try { const response = await fetch(form.action, { method: form.method, - body: data, + body: formDataObj, headers: { 'Accept': 'application/json', }, @@ -41,21 +41,22 @@ export default function FeedbackPage() { }); form.reset(); - // Reset success message after 5 seconds + // Reset success message after 6 seconds setTimeout(() => { setStatus('idle'); - }, 5000); + }, 6000); } else { - const data = await response.json(); - if (data.errors) { - setErrorMessage(data.errors.map((error: { message: string }) => error.message).join(', ')); + const responseData = await response.json(); + if (responseData.errors) { + setErrorMessage(responseData.errors.map((error: { message: string }) => error.message).join(', ')); } else { - setErrorMessage('Oops! There was a problem submitting your form.'); + setErrorMessage('Oops! There was a problem submitting your form. Please try again.'); } setStatus('error'); } } catch (error) { - setErrorMessage('Oops! There was a problem submitting your form.'); + console.error('Form submission error:', error); + setErrorMessage('Oops! There was a problem submitting your form. Please check your connection and try again.'); setStatus('error'); } }; @@ -95,60 +96,149 @@ export default function FeedbackPage() { {status === 'success' ? ( + {/* Animated background circles */} + + + - - - + + + + + + + + {/* Confetti effect using dots */} + {[...Array(12)].map((_, i) => ( + + ))} + + + Thanks for your submission! + + + Your feedback helps me improve my services. + + + {/* Subtle pulse animation */} + - - Thanks for your submission! - - - Your feedback helps me improve my services. - ) : ( { setStatus('idle'); - }, 5000); + }, 6000); } else { - const data = await response.json(); - if (data.errors) { - setErrorMessage(data.errors.map((error: { message: string }) => error.message).join(', ')); + const responseData = await response.json(); + if (responseData.errors) { + setErrorMessage(responseData.errors.map((error: { message: string }) => error.message).join(', ')); } else { - setErrorMessage('Oops! There was a problem submitting your form.'); + setErrorMessage('Oops! There was a problem submitting your form. Please try again.'); } setStatus('error'); } } catch (error) { - setErrorMessage('Oops! There was a problem submitting your form.'); + console.error('Form submission error:', error); + setErrorMessage('Oops! There was a problem submitting your form. Please check your connection and try again.'); setStatus('error'); } }; @@ -100,60 +101,149 @@ export default function Contact() { {status === 'success' ? ( + {/* Animated background circles */} + + + - - - + + + + + + + + {/* Confetti effect using dots */} + {[...Array(12)].map((_, i) => ( + + ))} + + + Thank you for your message! + + + I'll get back to you soon. + + + {/* Subtle pulse animation */} + - - Thank you for your message! - - - I'll get back to you soon. - ) : (