Merged in fix/SW-1491-SW-1500-link-in-hotel-card-to-map (pull request #1707)

fix(SW-1491-SW-1500): address on hotel card should go to map, remove link on maplisting view

* fix(SW-1491-SW-1500): address on hotel card should go to map, remove link on maplisting view

* fix(SW-1491-SW-1500): fix comment

* fix(SW-1491-SW-1500): add underscore


Approved-by: Niclas Edenvin
This commit is contained in:
Bianca Widstam
2025-04-03 06:56:23 +00:00
parent 0215c8428f
commit 83aedd7dbb
6 changed files with 93 additions and 75 deletions

View File

@@ -1,6 +1,6 @@
"use client"
import { useMap } from "@vis.gl/react-google-maps"
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { useCallback, useMemo, useRef, useState } from "react"
import { useIntl } from "react-intl"
import { useMediaQuery } from "usehooks-ts"
@@ -52,7 +52,7 @@ export default function SelectHotelContent({
const listingContainerRef = useRef<HTMLDivElement | null>(null)
const activeFilters = useHotelFilterStore((state) => state.activeFilters)
const { activeHotelCard, activeHotelPin } = useHotelsMapStore()
const { activeHotelPin } = useHotelsMapStore()
const { showBackToTop, scrollToTop } = useScrollToTop({
threshold: 490,
@@ -63,23 +63,22 @@ export default function SelectHotelContent({
(state) => state.activeCodeFilter
)
const coordinates = useMemo(
() =>
isAboveMobile
? cityCoordinates
: { ...cityCoordinates, lat: cityCoordinates.lat - 0.006 },
[isAboveMobile, cityCoordinates]
)
const coordinates = useMemo(() => {
if (activeHotelPin) {
const hotel = hotels.find((hotel) => hotel.hotel.name === activeHotelPin)
useEffect(() => {
if (listingContainerRef.current) {
const activeElement =
listingContainerRef.current.querySelector(`[data-active="true"]`)
if (activeElement) {
activeElement.scrollIntoView({ behavior: "smooth", block: "nearest" })
if (hotel && hotel.hotel.location) {
return {
lat: hotel.hotel.location.latitude,
lng: hotel.hotel.location.longitude,
}
}
}
}, [activeHotelCard, activeHotelPin])
return isAboveMobile
? cityCoordinates
: { ...cityCoordinates, lat: cityCoordinates.lat - 0.006 }
}, [activeHotelPin, hotels, isAboveMobile, cityCoordinates])
const filteredHotelPins = useMemo(() => {
const updatedHotelsList = bookingCode