"use client" import { APIProvider } from "@vis.gl/react-google-maps" import { useRouter, useSearchParams } from "next/navigation" import { useEffect, useState } from "react" import { useIntl } from "react-intl" import { selectHotel } from "@/constants/routes/hotelReservation" import { CloseIcon, CloseLargeIcon } from "@/components/Icons" import InteractiveMap from "@/components/Maps/InteractiveMap" import Button from "@/components/TempDesignSystem/Button" import useLang from "@/hooks/useLang" import HotelListing from "./HotelListing" import styles from "./selectHotelMap.module.css" import { SelectHotelMapProps } from "@/types/components/hotelReservation/selectHotel/map" export default function SelectHotelMap({ apiKey, coordinates, hotelPins, mapId, isModal, hotels, }: SelectHotelMapProps) { const searchParams = useSearchParams() const router = useRouter() const lang = useLang() const intl = useIntl() const [activeHotelPin, setActiveHotelPin] = useState(null) const [showBackToTop, setShowBackToTop] = useState(false) useEffect(() => { const hotelListingElement = document.querySelector( `.${styles.listingContainer}` ) if (!hotelListingElement) return const handleScroll = () => { const hasScrolledPast = hotelListingElement.scrollTop > 490 setShowBackToTop(hasScrolledPast) } hotelListingElement.addEventListener("scroll", handleScroll) return () => hotelListingElement.removeEventListener("scroll", handleScroll) }, []) function scrollToTop() { const hotelListingElement = document.querySelector( `.${styles.listingContainer}` ) hotelListingElement?.scrollTo({ top: 0, behavior: "smooth" }) } function handleModalDismiss() { router.back() } function handlePageRedirect() { router.push(`${selectHotel[lang]}?${searchParams.toString()}`) } const closeButton = ( ) return (
Filter and sort {/* TODO: Add filter and sort button */}
{showBackToTop && ( )}
) }