diff --git a/components/Contact/ContactForm.jsx b/components/Contact/ContactForm.jsx
index ae00054..a499b8e 100644
--- a/components/Contact/ContactForm.jsx
+++ b/components/Contact/ContactForm.jsx
@@ -35,13 +35,76 @@ function ContactForm() {
const handleSubmit = (e) => {
e.preventDefault();
+
+ // Frontend validation before sending
+ if (!formData.name.trim() || formData.name.trim().length < 2) {
+ toast.error("Name must be at least 2 characters long.", {
+ position: "top-center",
+ autoClose: 5000,
+ theme: "colored"
+ });
+ return;
+ }
+
+ if (!formData.email.trim()) {
+ toast.error("Email is required.", {
+ position: "top-center",
+ autoClose: 5000,
+ theme: "colored"
+ });
+ return;
+ }
+
+ if (emailError) {
+ toast.error("Please enter a valid email address.", {
+ position: "top-center",
+ autoClose: 5000,
+ theme: "colored"
+ });
+ return;
+ }
+
+ if (!formData.message.trim() || formData.message.trim().length < 10) {
+ toast.error("Message must be at least 10 characters long.", {
+ position: "top-center",
+ autoClose: 5000,
+ theme: "colored"
+ });
+ return;
+ }
+
+ if (formData.message.trim().length > 2000) {
+ toast.error("Message must be less than 2000 characters.", {
+ position: "top-center",
+ autoClose: 5000,
+ theme: "colored"
+ });
+ return;
+ }
+
setIsSubmitting(true);
+ // Log the data being sent for debugging
+ console.log("📤 Sending form data:", {
+ name: formData.name.trim(),
+ email: formData.email.trim(),
+ message: formData.message.trim(),
+ lengths: {
+ name: formData.name.trim().length,
+ email: formData.email.trim().length,
+ message: formData.message.trim().length
+ }
+ });
+
axios
- .post("/api/v1/contact", formData)
+ .post("/api/v1/contact", {
+ name: formData.name.trim(),
+ email: formData.email.trim(),
+ message: formData.message.trim()
+ })
.then((response) => {
- console.log("Response:", response.data);
- toast.success("Your form has been submitted successfully!", {
+ console.log("✅ Response:", response.data);
+ toast.success(response.data.message || "Your form has been submitted successfully!", {
position: "top-center",
autoClose: 5000,
hideProgressBar: false,
@@ -56,25 +119,39 @@ function ContactForm() {
})
.catch((error) => {
console.error("Error:", error);
- toast.error(
- "There was an error submitting your form. Please try again.",
- {
- position: "top-center",
- autoClose: 5000,
- hideProgressBar: false,
- closeOnClick: true,
- pauseOnHover: true,
- draggable: true,
- progress: undefined,
- theme: "colored"
- }
- );
+
+ // Get specific error message from API response
+ let errorMessage = "There was an error submitting your form. Please try again.";
+
+ if (error.response && error.response.data) {
+ errorMessage = error.response.data.message || errorMessage;
+ console.log("API Error Details:", error.response.data);
+ }
+
+ toast.error(errorMessage, {
+ position: "top-center",
+ autoClose: 7000,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: true,
+ draggable: true,
+ progress: undefined,
+ theme: "colored"
+ });
setIsSubmitting(false);
});
};
- const isFormValid =
- formData.name && formData.email && formData.message && !emailError;
+ const isFormValid = () => {
+ return (
+ formData.name.trim().length >= 2 &&
+ formData.name.trim().length <= 100 &&
+ formData.email.trim() &&
+ !emailError &&
+ formData.message.trim().length >= 10 &&
+ formData.message.trim().length <= 2000
+ );
+ };
return (
<>
@@ -94,44 +171,68 @@ function ContactForm() {
>
Send Us Your Queries
-
-
- {emailError && (
- {emailError}
- )}
-
+
+
0 && formData.name.length < 2 ? 'border-red-500' : 'border-gray'} text-white font-dmSans bg-bg_black outline-none w-full my-8 mt-10`}
+ />
+ {formData.name.length > 0 && formData.name.length < 2 && (
+
Name must be at least 2 characters
+ )}
+
+ {formData.name.length}/100
+
+
+
+
+
+ {emailError && (
+
{emailError}
+ )}
+
+
+
diff --git a/components/Home/Gallery.jsx b/components/Home/Gallery.jsx
index a9fbeed..666cb8f 100644
--- a/components/Home/Gallery.jsx
+++ b/components/Home/Gallery.jsx
@@ -20,6 +20,8 @@ import img8 from "../../public/Home/8.JPG";
import img9 from "../../public/Home/9.JPG";
import img10 from "../../public/Home/10.JPG";
import img11 from "../../public/Home/11.jpg";
+import img12 from "../../public/Home/12.JPG";
+import img13 from "../../public/Home/13.JPG";
const serviceData = [
img1,
@@ -32,7 +34,9 @@ const serviceData = [
img8,
img9,
img10,
- img11
+ img11,
+ img12,
+ img13
];
const ServiceSlider = () => {
@@ -83,14 +87,14 @@ const ServiceSlider = () => {
// slideShadows: false
// }}
pagination={{
- dynamicBullets: true
+ clickable: true
}}
autoplay={{
delay: 2000,
- disableOnInteraction: true
+ pauseOnHover: true
}}
modules={[Autoplay, Pagination]}
- className="overflow-hidden"
+ className="overflow-hidden pb-12"
>
{serviceData.map((item, index) => (
diff --git a/components/Home/Sponsors.jsx b/components/Home/Sponsors.jsx
index ee021de..650e2d7 100644
--- a/components/Home/Sponsors.jsx
+++ b/components/Home/Sponsors.jsx
@@ -8,41 +8,62 @@ import { useEffect, useState } from "react";
const Sponsors = () => {
const [sponsors, setSponsors] = useState([]);
+ const [loading, setLoading] = useState(true);
+
useEffect(() => {
const fetchSponsors = async () => {
try {
+ setLoading(true);
const response = await fetch("../api/v1/sponsers");
- const result = await response.json();
+ const result = await response.json();
console.log("hello")
setSponsors(result.data);
} catch (error) {
console.error("Error fetching sponsors:", error);
+ } finally {
+ setLoading(false);
}
};
fetchSponsors();
}, []);
+ // Skeleton component for loading state
+ const SponsorSkeleton = () => (
+
+ );
+
return (
Sponsors
- {sponsors.map((sponsor, index) => (
-
+ {loading ? (
+ // Show 6 skeleton components while loading
+ Array.from({ length: 6 }, (_, index) => (
+
+ ))
+ ) : (
+ sponsors.map((sponsor, index) => (
-

+
+

+
-
- ))}
+ ))
+ )}
);
diff --git a/components/Shared/Scroll.jsx b/components/Shared/Scroll.jsx
index 1d34774..5ce18cd 100644
--- a/components/Shared/Scroll.jsx
+++ b/components/Shared/Scroll.jsx
@@ -26,7 +26,7 @@ const ScrollToTopButton = () => {
}, []);
return (
-
+
{isVisible && (