diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 70e4611..e9caaea 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -13,11 +13,11 @@ const Home = () => { return saved ? JSON.parse(saved) : []; }); - // State for hero slideshow current image index + // State for hero slideshow current image index const [currentIndex, setCurrentIndex] = useState(0); // State to prevent multiple transitions at once const [isTransitioning, setIsTransitioning] = useState(false); - + // Reference to search container for detecting outside clicks const searchRef = useRef(null); const navigate = useNavigate(); @@ -30,51 +30,9 @@ const Home = () => { "Chicago", "San Francisco", ]; - - - - useEffect(() => { - const interval = setInterval(() => { - setIsTransitioning(true); - setCurrentIndex(prev => (prev + 1) % heroImages.length); - - setTimeout(() => setIsTransitioning(false), 700); - }, 3300); - - return () => clearInterval(interval); -}, []); - - - // Function to go to next slide - const nextSlide = () => { - if (!isTransitioning) { - setIsTransitioning(true); - setCurrentIndex((prev) => (prev + 1) % heroImages.length); - setTimeout(() => setIsTransitioning(false), 700); - } - }; - - // Function to go to previous slide - const prevSlide = () => { - if (!isTransitioning) { - setIsTransitioning(true); - setCurrentIndex((prev) => (prev - 1 + heroImages.length) % heroImages.length); - setTimeout(() => setIsTransitioning(false), 700); - } - }; - // Function to jump to specific slide - const goToSlide = (index) => { - if (!isTransitioning && index !== currentIndex) { - setIsTransitioning(true); - setCurrentIndex(index); - setTimeout(() => setIsTransitioning(false), 700); - } - }; - - + // Function to handle clicks outside the search dropdown useEffect(() => { - // Handle clicks outside the search dropdown to close it const handleClickOutside = (event) => { if (searchRef.current && !searchRef.current.contains(event.target)) { setIsSearchFocused(false); @@ -91,7 +49,7 @@ const Home = () => { const handleSearchSubmit = (e) => { e.preventDefault(); if (searchQuery.trim()) { - // Add to recent searches (avoid duplicates and limit to 5) + // Add to recent searches const updatedSearches = [ searchQuery.trim(), ...recentSearches.filter((search) => search !== searchQuery.trim()), @@ -105,8 +63,8 @@ const Home = () => { }; // Function to handle click on a search suggestion + // (KEPT FROM UPSTREAM: This is useful logic the original creator added) const handleSuggestionClick = (suggestion) => { - // Add to recent searches const updatedSearches = [ suggestion, ...recentSearches.filter((search) => search !== suggestion), @@ -116,13 +74,12 @@ const Home = () => { navigate(`/listings?location=${encodeURIComponent(suggestion)}`); }; - // Function to clear all recent searches from localStorage + // Function to clear all recent searches const clearRecentSearches = () => { localStorage.setItem("recentSearches", JSON.stringify([])); setRecentSearches([]); }; - // Sample featured destinations data const destinations = [ { @@ -180,85 +137,47 @@ const Home = () => { }, ]; - // Array of hero images for the slideshow - const heroImages = [ - { - url: "https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80", - alt: "Luxurious vacation home" - }, - { - url: "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?ixlib=rb-4.0.3&auto=format&fit=crop&w=1950&q=80", - alt: "Mountain landscape retreat" - }, - { - url: "https://images.unsplash.com/photo-1540206395-68808572332f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1950&q=80", - alt: "Tropical beach paradise" - }, - { - url: "https://images.unsplash.com/photo-1469474968028-56623f02e42e?ixlib=rb-4.0.3&auto=format&fit=crop&w=1950&q=80", - alt: "Forest wilderness escape" - }, - { - url: "https://images.unsplash.com/photo-1511593358241-7eea1f3c84e5?ixlib=rb-4.0.3&auto=format&fit=crop&w=1950&q=80", - alt: "Coastal sunset view" - } - ]; - return ( -
+ Book your escape to paradise. Unforgettable moments await. +
+ ++ Discover a curated collection of premium hotels, cozy suites, and private villas available for rent. Enjoy exclusive deals and world-class amenities for your dream stay. +
+