Skip to content

Commit 16b7090

Browse files
authored
Merge pull request #26 from MickyMik/dev
Update Contact.tsx
2 parents 5719af8 + f01edf6 commit 16b7090

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/components/Contact.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import { zodResolver } from "@hookform/resolvers/zod";
1010
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
1111
import emailjs from "emailjs-com";
1212

13-
// Form validation schema
13+
// ✅ EmailJS Configuration (Replace with your actual IDs)
14+
const SERVICE_ID = "service_t6so8r5"; // Remplace par ton Service ID EmailJS
15+
const TEMPLATE_ID = "template_meqf9bp"; // Remplace par ton Template ID EmailJS
16+
const PUBLIC_KEY = "IobH6oMwMiIETnEVh"; // Remplace par ta clé publique EmailJS
17+
18+
// ✅ Validation Schema avec Zod // Form validation schema
1419
const contactFormSchema = z.object({
1520
name: z.string()
1621
.min(2, "Name must be at least 2 characters")
@@ -45,7 +50,7 @@ const Contact = () => {
4550

4651
const handleSubmit = async (data: ContactFormData) => {
4752
try {
48-
// Empêche spam en vérifiant le délai // Rate limiting check (simple client-side implementation)
53+
// ✅ Anti-Spam: Vérifie délai entre envois // Empêche spam en vérifiant le délai // Rate limiting check (simple client-side implementation)
4954
const lastSubmission = localStorage.getItem("lastContactSubmission");
5055
const now = Date.now();
5156
if (lastSubmission && now - parseInt(lastSubmission) < 60000) {
@@ -57,31 +62,30 @@ const Contact = () => {
5762
return;
5863
}
5964

60-
// Sanitize data (additional protection)
65+
// ✅ Nettoyage des données
6166
const sanitizedData = {
6267
name: data.name.trim(),
6368
email: data.email.trim().toLowerCase(),
6469
subject: data.subject.trim(),
6570
message: data.message.trim()
6671
};
6772

68-
// Appel EmailJS
73+
// ✅ Envoi via EmailJS
6974
await emailjs.send(
70-
"service_t6so8r5", // Remplace par ton Service ID
71-
"template_meqf9bp", // Remplace par ton Template ID
75+
SERVICE_ID,
76+
TEMPLATE_ID,
7277
{
73-
name: data.name,
74-
email: data.email,
75-
subject: data.subject,
76-
message: data.message
78+
name: sanitizedData.name,
79+
email: sanitizedData.email,
80+
subject: sanitizedData.subject,
81+
message: sanitizedData.message
7782
},
78-
"IobH6oMwMiIETnEVh" // Remplace par ta clé publique
83+
PUBLIC_KEY
7984
);
8085

81-
// Store submission timestamp
86+
// ✅ Sauvegarde du timestamp pour éviter spam
8287
localStorage.setItem("lastContactSubmission", now.toString());
8388

84-
// Here you would typically send the form data to your backend
8589
toast({
8690
title: "Message sent!",
8791
description: "Thank you for your message. I'll get back to you soon."
@@ -233,7 +237,7 @@ const Contact = () => {
233237
</CardContent>
234238
</Card>
235239

236-
{/* Contact Information */}
240+
{/* Contact Info + Social Links */}
237241
<div className="space-y-8">
238242
<Card className="shadow-card">
239243
<CardContent className="p-8">

0 commit comments

Comments
 (0)