From 0af24643ffac705e3c528c6081f2bed3a478be8d Mon Sep 17 00:00:00 2001
From: louispaulb
Date: Fri, 27 Mar 2026 15:28:06 -0400
Subject: [PATCH] fix: contact form sends to API, remove dead links, secure
.env
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Contact form now POSTs to /rpc/contact (www-api → n8n webhook)
- Footer links: Mon compte → store.targo.ca, placeholder # → /support
- .env added to .gitignore (Supabase keys should not be committed)
Co-Authored-By: Claude Opus 4.6 (1M context)
---
.gitignore | 1 +
src/components/layout/Footer.tsx | 8 ++++----
src/components/sections/Contact.tsx | 32 +++++++++++++++++------------
3 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/.gitignore b/.gitignore
index a547bf3..7ceb59f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
+.env
diff --git a/src/components/layout/Footer.tsx b/src/components/layout/Footer.tsx
index d44865d..08c7740 100644
--- a/src/components/layout/Footer.tsx
+++ b/src/components/layout/Footer.tsx
@@ -31,8 +31,8 @@ La fiabilité, la performance et l'expertise à proximité pour propulser vos co
@@ -79,8 +79,8 @@ La fiabilité, la performance et l'expertise à proximité pour propulser vos co
© {new Date().getFullYear()} TARGO Communications. Tous droits réservés.
diff --git a/src/components/sections/Contact.tsx b/src/components/sections/Contact.tsx
index 7a6291f..9b375cf 100644
--- a/src/components/sections/Contact.tsx
+++ b/src/components/sections/Contact.tsx
@@ -42,20 +42,26 @@ const Contact = () => {
message: "",
});
- const handleSubmit = (e: React.FormEvent) => {
+ const [sending, setSending] = useState(false);
+
+ const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
- toast({
- title: "Message envoyé!",
- description: "Nous vous répondrons dans les plus brefs délais.",
- });
- setFormData({
- name: "",
- address: "",
- postalCode: "",
- email: "",
- phone: "",
- message: "",
- });
+ setSending(true);
+ try {
+ await fetch('/rpc/contact', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(formData),
+ });
+ toast({
+ title: "Message envoyé!",
+ description: "Nous vous répondrons dans les plus brefs délais.",
+ });
+ setFormData({ name: "", address: "", postalCode: "", email: "", phone: "", message: "" });
+ } catch {
+ toast({ title: "Erreur", description: "Impossible d'envoyer. Réessayez ou appelez-nous.", variant: "destructive" });
+ }
+ setSending(false);
};
const handleChange = (e: React.ChangeEvent) => {