From 4bc59072b6a2ab2deb958d55c1144cc165288fd8 Mon Sep 17 00:00:00 2001 From: Yogamnan Date: Mon, 3 Mar 2025 14:21:00 +0700 Subject: [PATCH] penambahan fitur 3 huruf setelah (.) pada form email --- src/components/beranda/Hero.jsx | 6 +-- src/components/beranda/Kenapa.jsx | 9 ++-- src/components/beranda/Mitra.jsx | 4 +- src/components/contact/FormSection.jsx | 40 ++++++++++++++++-- .../solusi/HeadCorporate/HeadCorporate.jsx | 4 +- .../solusi/HeadPersonal/HeadPersonal.jsx | 4 +- .../solusi/HeadStartup/HeadStartup.jsx | 4 +- .../MengapaCorporate/MengapaCorporate.jsx | 10 ++--- .../solusi/MengapaStartup/MengapaStartup.jsx | 10 ++--- .../MengapapPersonal/MengapapPersonal.jsx | 42 +++++++++---------- 10 files changed, 83 insertions(+), 50 deletions(-) diff --git a/src/components/beranda/Hero.jsx b/src/components/beranda/Hero.jsx index cc91419..99de30e 100644 --- a/src/components/beranda/Hero.jsx +++ b/src/components/beranda/Hero.jsx @@ -34,7 +34,7 @@ function Hero() { }, []); return ( -
+
{/* Left Section */} @@ -72,12 +72,12 @@ function Hero() { className="flex flex-col sm:flex-row gap-4 md:-mt-96 order-3 lg:order-none" id="button-section" > - - diff --git a/src/components/beranda/Kenapa.jsx b/src/components/beranda/Kenapa.jsx index 715d6f3..2e221e8 100644 --- a/src/components/beranda/Kenapa.jsx +++ b/src/components/beranda/Kenapa.jsx @@ -87,8 +87,9 @@ function Kenapa() {
+ Konsultasi Gratis - - + + { const interval = setInterval(() => { handleNext(); - }, 8900); // Slider bergerak setiap 4 detik + }, 8900); - return () => clearInterval(interval); // Membersihkan interval saat komponen unmount + return () => clearInterval(interval); }, [currentIndex]); return ( diff --git a/src/components/contact/FormSection.jsx b/src/components/contact/FormSection.jsx index 3a854fb..ffb051a 100644 --- a/src/components/contact/FormSection.jsx +++ b/src/components/contact/FormSection.jsx @@ -1,6 +1,6 @@ "use client" -import { useEffect } from "react" +import { useEffect, useState } from "react" import { useLocation } from "react-router-dom" import ReCAPTCHA from "react-google-recaptcha" import { motion, useAnimation } from "framer-motion" @@ -15,6 +15,9 @@ const ContactForm = () => { const [ref, inView] = useInView({ threshold: 0.1, // Trigger when 10% of the element is in view }) + const [email, setEmail] = useState(""); + const [error, setError] = useState(""); + const [isValid, setIsValid] = useState(false); // Untuk validasi tombol submit useEffect(() => { if (inView) { @@ -43,6 +46,32 @@ const ContactForm = () => { visible: { opacity: 1, y: 0, transition: { duration: 0.8, ease: "easeOut" } }, } + const handleChange = (e) => { + const value = e.target.value; + setEmail(value); + + // Regex untuk memastikan hanya 3 huruf setelah titik + const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{3}$/; + + if (!emailPattern.test(value) && value !== "") { + setError("Domain email harus memiliki 3 huruf setelah titik."); + setIsValid(false); // Tidak valid, tombol submit dinonaktifkan + } else { + setError(""); + setIsValid(true); // Valid, tombol submit bisa digunakan + } + }; + + const handleSubmit = (e) => { + e.preventDefault(); + if (!isValid) { + alert("Silakan perbaiki email Anda sebelum mengirim formulir."); + return; + } + alert("Formulir berhasil dikirim!"); + // Tambahkan logika pengiriman data di sini + }; + return (
{ />
- + + {error &&

{error}

}
@@ -153,8 +185,8 @@ const ContactForm = () => { diff --git a/src/components/solusi/HeadCorporate/HeadCorporate.jsx b/src/components/solusi/HeadCorporate/HeadCorporate.jsx index bd6dc7b..f609177 100644 --- a/src/components/solusi/HeadCorporate/HeadCorporate.jsx +++ b/src/components/solusi/HeadCorporate/HeadCorporate.jsx @@ -65,13 +65,13 @@ export default function HeadCorporate() { animate={buttonInView ? { opacity: 1, y: 0 } : {}} transition={{ duration: 0.8 }} > - - - - - - Coba Sekarang diff --git a/src/components/solusi/MengapaStartup/MengapaStartup.jsx b/src/components/solusi/MengapaStartup/MengapaStartup.jsx index 0ef8eb2..6e74b40 100644 --- a/src/components/solusi/MengapaStartup/MengapaStartup.jsx +++ b/src/components/solusi/MengapaStartup/MengapaStartup.jsx @@ -57,16 +57,16 @@ function Kenapa() { ))} - - - Coba Sekarang diff --git a/src/components/solusi/MengapapPersonal/MengapapPersonal.jsx b/src/components/solusi/MengapapPersonal/MengapapPersonal.jsx index 50ad79f..7cbe0cb 100644 --- a/src/components/solusi/MengapapPersonal/MengapapPersonal.jsx +++ b/src/components/solusi/MengapapPersonal/MengapapPersonal.jsx @@ -9,14 +9,14 @@ function Kenapa() { return (
- {/* Image Section */} - {/* Text Section */} - ( - - Check - {text} - - ))} + + Check + {text} + + ))} - - - Coba Sekarang