diff --git a/app/contact/page.js b/app/contact/page.js index dd3e36f..c943f28 100644 --- a/app/contact/page.js +++ b/app/contact/page.js @@ -1,60 +1,257 @@ "use client"; -import React from 'react'; -import Navbar from '../components/Navbar'; -import Footer from '../components/Footer'; +import { useState } from "react"; +import Navbar from "../components/Navbar"; +import Footer from "../components/Footer"; const ContactPage = () => { - return ( -
-
- -
- -
-
-

Contact Us

-

- Welcome to FarmRuler! We &apos re on a mission to build an Incredible Full-Stack Web Application for Agriculture and Farming enthusiasts. -

-
-
- - -
-
- - -
-
- - -
- - -
-
- -
- -
-

Features

-
    -
  • Simple and Clean UI to Display Weather Conditions
  • -
  • Tool connecting the agricultural community with NASA datasets
  • -
  • Integrate NASA datasets to support farmers decision-making
  • -
  • Farmers can determine resources for selected spatial and temporal ranges
  • -
  • Many More...
  • -
-
-
- -
-
-
- - ); + const [formData, setFormData] = useState({ + name: "", + email: "", + message: "", + }); + const [errors, setErrors] = useState({}); + const [isSubmitting, setIsSubmitting] = useState(false); + const [submitSuccess, setSubmitSuccess] = useState(false); + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData((prev) => ({ ...prev, [name]: value })); + // Clear error when user starts typing + if (errors[name]) { + setErrors((prev) => ({ ...prev, [name]: "" })); + } + }; + + const validateForm = () => { + let tempErrors = {}; + if (!formData.name.trim()) tempErrors.name = "Name is required"; + if (!formData.email.trim()) { + tempErrors.email = "Email is required"; + } else if (!/\S+@\S+\.\S+/.test(formData.email)) { + tempErrors.email = "Email is invalid"; + } + if (!formData.message.trim()) tempErrors.message = "Message is required"; + setErrors(tempErrors); + return Object.keys(tempErrors).length === 0; + }; + + const handleSubmit = (e) => { + e.preventDefault(); + if (validateForm()) { + setIsSubmitting(true); + // Simulate API call + setTimeout(() => { + setIsSubmitting(false); + setSubmitSuccess(true); + setFormData({ name: "", email: "", message: "" }); + setTimeout(() => setSubmitSuccess(false), 3000); + }, 1500); + } + }; + + return ( +
+ + +
+
+
+

+ Contact Us +

+

+ Welcome to FarmRuler! We're on a mission to build an + Incredible Full-Stack Web Application for Agriculture and Farming + enthusiasts. +

+
+
+ + + {errors.name && ( +

{errors.name}

+ )} +
+
+ + + {errors.email && ( +

{errors.email}

+ )} +
+
+ + + {errors.message && ( +

{errors.message}

+ )} +
+ +
+ {submitSuccess && ( +
+ Message sent successfully! +
+ )} +
+ +
+ +
+

+ Features +

+
    + {[ + "Simple and Clean UI to Display Weather Conditions", + "Tool connecting the agricultural community with NASA datasets", + "Integrate NASA datasets to support farmers decision-making", + "Farmers can determine resources for selected spatial and temporal ranges", + "Many More...", + ].map((feature, index) => ( +
  • + + + + {feature} +
  • + ))} +
+
+
+
+ +
+ ); }; export default ContactPage;