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,7 +1,3 @@
.hotelListing {
display: none;
}
.hotelListingMobile {
display: none;
overflow-x: auto;
@@ -16,16 +12,9 @@
display: flex;
}
@media (min-width: 768px) {
.hotelListing {
display: block;
width: 100%;
overflow-y: auto;
padding-top: var(--Spacing-x2);
}
.hotelListingMobile,
.hotelListingMobile[data-open="true"] {
display: none;
}
.hotelListing {
display: block;
width: 100%;
overflow-y: auto;
padding-top: var(--Spacing-x2);
}

View File

@@ -1,5 +1,7 @@
"use client"
import { useMediaQuery } from "usehooks-ts"
import { useHotelsMapStore } from "@/stores/hotels-map"
import HotelCardDialogListing from "@/components/HotelReservation/HotelCardDialogListing"
@@ -12,17 +14,21 @@ import type { HotelListingProps } from "@/types/components/hotelReservation/sele
export default function HotelListing({ hotels }: HotelListingProps) {
const { activeHotelPin } = useHotelsMapStore()
const isMobile = useMediaQuery("(max-width: 767px)")
return (
<>
<div className={styles.hotelListing}>
<HotelCardListing
hotelData={hotels}
type={HotelCardListingTypeEnum.MapListing}
/>
</div>
<div className={styles.hotelListingMobile} data-open={!!activeHotelPin}>
<HotelCardDialogListing hotels={hotels} />
</div>
{isMobile ? (
<div className={styles.hotelListingMobile} data-open={!!activeHotelPin}>
<HotelCardDialogListing hotels={hotels} />
</div>
) : (
<div className={styles.hotelListing}>
<HotelCardListing
hotelData={hotels}
type={HotelCardListingTypeEnum.MapListing}
/>
</div>
)}
</>
)
}

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