diff --git a/components/Hero.jsx b/components/Hero.jsx index 569e2af..6205e19 100644 --- a/components/Hero.jsx +++ b/components/Hero.jsx @@ -1,3 +1,5 @@ +import PropertySearchForm from './PropertySearchForm'; + const Hero = () => { return (
@@ -10,45 +12,7 @@ const Hero = () => { Discover the perfect property that suits your needs.

- {/* */} -
-
- - -
-
- - -
- -
+
); diff --git a/components/PropertySearchForm.jsx b/components/PropertySearchForm.jsx new file mode 100644 index 0000000..3c27e99 --- /dev/null +++ b/components/PropertySearchForm.jsx @@ -0,0 +1,72 @@ +'use client'; +import { useState } from 'react'; +import { useRouter } from 'next/navigation'; + +const PropertySearchForm = () => { + const [location, setLocation] = useState(''); + const [propertyType, setPropertyType] = useState('All'); + + const router = useRouter(); + + const handleSubmit = (e) => { + e.preventDefault(); + + if (location === '' && propertyType === 'All') { + router.push('/properties'); + } else { + const query = `?location=${location}&propertyType=${propertyType}`; + + router.push(`/properties/search-results${query}`); + } + }; + + return ( +
+
+ + setLocation(e.target.value)} + /> +
+
+ + +
+ +
+ ); +}; + +export default PropertySearchForm;