fix: e.currentTarget is null
This commit is contained in:
@@ -48,18 +48,20 @@ export default function Contact() {
|
|||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
const form = e.currentTarget;
|
||||||
|
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
setError("");
|
setError("");
|
||||||
setIsSubmitted(false);
|
setIsSubmitted(false);
|
||||||
|
|
||||||
// Vérifier que le captcha est validé
|
|
||||||
if (!captchaToken) {
|
if (!captchaToken) {
|
||||||
setError("Veuillez valider le captcha");
|
setError("Veuillez valider le captcha");
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formData = new FormData(e.currentTarget);
|
const formData = new FormData(form);
|
||||||
const data = {
|
const data = {
|
||||||
name: formData.get("name") as string,
|
name: formData.get("name") as string,
|
||||||
email: formData.get("email") as string,
|
email: formData.get("email") as string,
|
||||||
@@ -85,7 +87,7 @@ export default function Contact() {
|
|||||||
console.log("Succès:", result);
|
console.log("Succès:", result);
|
||||||
|
|
||||||
setIsSubmitted(true);
|
setIsSubmitted(true);
|
||||||
e.currentTarget.reset();
|
form.reset();
|
||||||
setCaptchaToken("");
|
setCaptchaToken("");
|
||||||
setTimeout(() => setIsSubmitted(false), 5000);
|
setTimeout(() => setIsSubmitted(false), 5000);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -136,7 +138,7 @@ export default function Contact() {
|
|||||||
<div className="inline-flex items-center gap-2 bg-linear-to-r from-blue-500/10 to-purple-500/10 rounded-full px-4 py-2 mb-4">
|
<div className="inline-flex items-center gap-2 bg-linear-to-r from-blue-500/10 to-purple-500/10 rounded-full px-4 py-2 mb-4">
|
||||||
<Sparkles className="w-4 h-4 text-blue-400" />
|
<Sparkles className="w-4 h-4 text-blue-400" />
|
||||||
<span className="text-sm font-semibold text-slate-300">
|
<span className="text-sm font-semibold text-slate-300">
|
||||||
Restons en contact
|
Entrons en contact
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-4xl md:text-5xl font-bold text-white mb-4">
|
<h2 className="text-4xl md:text-5xl font-bold text-white mb-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user