Merged in feat/SW-344-hotel-map-pins-mobile (pull request #880)

Feat/SW-344 hotel map pins mobile

Approved-by: Niclas Edenvin
This commit is contained in:
Pontus Dreij
2024-11-13 13:19:44 +00:00
22 changed files with 323 additions and 113 deletions

View File

@@ -3,6 +3,7 @@ import { notFound } from "next/navigation"
import { env } from "@/env/server" import { env } from "@/env/server"
import { getLocations } from "@/lib/trpc/memoizedRequests" import { getLocations } from "@/lib/trpc/memoizedRequests"
import { getHotelPins } from "@/components/HotelReservation/HotelCardDialogListing/utils"
import SelectHotelMap from "@/components/HotelReservation/SelectHotel/SelectHotelMap" import SelectHotelMap from "@/components/HotelReservation/SelectHotel/SelectHotelMap"
import { import {
generateChildrenString, generateChildrenString,
@@ -11,11 +12,7 @@ import {
import { MapModal } from "@/components/MapModal" import { MapModal } from "@/components/MapModal"
import { setLang } from "@/i18n/serverContext" import { setLang } from "@/i18n/serverContext"
import { import { fetchAvailableHotels } from "../../utils"
fetchAvailableHotels,
getCentralCoordinates,
getHotelPins,
} from "../../utils"
import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams" import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams"
import type { LangParams, PageArgs } from "@/types/params" import type { LangParams, PageArgs } from "@/types/params"
@@ -61,16 +58,12 @@ export default async function SelectHotelMapPage({
const hotelPins = getHotelPins(hotels) const hotelPins = getHotelPins(hotels)
const centralCoordinates = getCentralCoordinates(hotelPins)
return ( return (
<MapModal> <MapModal>
<SelectHotelMap <SelectHotelMap
apiKey={googleMapsApiKey} apiKey={googleMapsApiKey}
coordinates={centralCoordinates}
hotelPins={hotelPins} hotelPins={hotelPins}
mapId={googleMapId} mapId={googleMapId}
isModal={true}
hotels={hotels} hotels={hotels}
/> />
</MapModal> </MapModal>

View File

@@ -87,38 +87,3 @@ export function getFiltersFromHotels(hotels: HotelData[]): CategorizedFilters {
{ facilityFilters: [], surroundingsFilters: [] } { facilityFilters: [], surroundingsFilters: [] }
) )
} }
export function getHotelPins(hotels: HotelData[]): HotelPin[] {
return hotels.map((hotel) => ({
coordinates: {
lat: hotel.hotelData.location.latitude,
lng: hotel.hotelData.location.longitude,
},
name: hotel.hotelData.name,
publicPrice: hotel.price?.regularAmount ?? null,
memberPrice: hotel.price?.memberAmount ?? null,
currency: hotel.price?.currency || null,
images: [
hotel.hotelData.hotelContent.images,
...(hotel.hotelData.gallery?.heroImages ?? []),
],
amenities: hotel.hotelData.detailedFacilities.slice(0, 3),
ratings: hotel.hotelData.ratings?.tripAdvisor.rating ?? null,
}))
}
export function getCentralCoordinates(hotels: HotelPin[]) {
const centralCoordinates = hotels.reduce(
(acc, pin) => {
acc.lat += pin.coordinates.lat
acc.lng += pin.coordinates.lng
return acc
},
{ lat: 0, lng: 0 }
)
centralCoordinates.lat /= hotels.length
centralCoordinates.lng /= hotels.length
return centralCoordinates
}

View File

@@ -3,13 +3,13 @@
import { Suspense, useEffect } from "react" import { Suspense, useEffect } from "react"
import { Dialog, Modal } from "react-aria-components" import { Dialog, Modal } from "react-aria-components"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { useMediaQuery } from "usehooks-ts"
import useDropdownStore from "@/stores/main-menu" import useDropdownStore from "@/stores/main-menu"
import { GiftIcon, SearchIcon, ServiceIcon } from "@/components/Icons" import { GiftIcon, SearchIcon, ServiceIcon } from "@/components/Icons"
import LanguageSwitcher from "@/components/LanguageSwitcher" import LanguageSwitcher from "@/components/LanguageSwitcher"
import { useHandleKeyUp } from "@/hooks/useHandleKeyUp" import { useHandleKeyUp } from "@/hooks/useHandleKeyUp"
import useMediaQuery from "@/hooks/useMediaQuery"
import HeaderLink from "../../HeaderLink" import HeaderLink from "../../HeaderLink"

View File

@@ -3,11 +3,11 @@
import { useEffect } from "react" import { useEffect } from "react"
import { Dialog, Modal } from "react-aria-components" import { Dialog, Modal } from "react-aria-components"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { useMediaQuery } from "usehooks-ts"
import useDropdownStore from "@/stores/main-menu" import useDropdownStore from "@/stores/main-menu"
import { useHandleKeyUp } from "@/hooks/useHandleKeyUp" import { useHandleKeyUp } from "@/hooks/useHandleKeyUp"
import useMediaQuery from "@/hooks/useMediaQuery"
import { getInitials } from "@/utils/user" import { getInitials } from "@/utils/user"
import Avatar from "../Avatar" import Avatar from "../Avatar"

View File

@@ -70,6 +70,10 @@
justify-content: center; justify-content: center;
} }
.address {
display: none;
}
@media screen and (min-width: 1367px) { @media screen and (min-width: 1367px) {
.card.pageListing { .card.pageListing {
grid-template-areas: grid-template-areas:
@@ -118,4 +122,12 @@
.pageListing .button { .pageListing .button {
width: 160px; width: 160px;
} }
.address {
display: block;
}
.addressMobile {
display: none;
}
} }

View File

@@ -1,6 +1,10 @@
"use client" "use client"
import { useParams } from "next/dist/client/components/navigation"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { Lang } from "@/constants/languages"
import { selectHotelMap } from "@/constants/routes/hotelReservation"
import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data" import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data"
import { PriceTagIcon, ScandicLogoIcon } from "@/components/Icons" import { PriceTagIcon, ScandicLogoIcon } from "@/components/Icons"
import TripAdvisorIcon from "@/components/Icons/TripAdvisor" import TripAdvisorIcon from "@/components/Icons/TripAdvisor"
@@ -26,6 +30,8 @@ export default function HotelCard({
state = "default", state = "default",
onHotelCardHover, onHotelCardHover,
}: HotelCardProps) { }: HotelCardProps) {
const params = useParams()
const lang = params.lang as Lang
const intl = useIntl() const intl = useIntl()
const { hotelData } = hotel const { hotelData } = hotel
@@ -74,9 +80,19 @@ export default function HotelCard({
<Title as="h4" textTransform="capitalize"> <Title as="h4" textTransform="capitalize">
{hotelData.name} {hotelData.name}
</Title> </Title>
<Footnote color="uiTextMediumContrast"> <Footnote color="uiTextMediumContrast" className={styles.address}>
{`${hotelData.address.streetAddress}, ${hotelData.address.city}`} {`${hotelData.address.streetAddress}, ${hotelData.address.city}`}
</Footnote> </Footnote>
<Link
className={styles.addressMobile}
href={`${selectHotelMap[lang]}?selectedHotel=${hotelData.name}`}
keepSearchParams
variant="underscored"
>
<Footnote color="burgundy">
{`${hotelData.address.streetAddress}, ${hotelData.address.city}`}
</Footnote>
</Link>
<Footnote color="uiTextMediumContrast"> <Footnote color="uiTextMediumContrast">
{`${hotelData.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`} {`${hotelData.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`}
</Footnote> </Footnote>

View File

@@ -18,6 +18,12 @@
position: relative; position: relative;
} }
.name {
height: 48px;
display: flex;
align-items: center;
}
.closeIcon { .closeIcon {
position: absolute; position: absolute;
top: 7px; top: 7px;
@@ -52,7 +58,7 @@
.facilities { .facilities {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: var(--Spacing-x1); gap: 0 var(--Spacing-x1);
} }
.facilitiesItem { .facilitiesItem {
@@ -67,7 +73,6 @@
background: var(--Base-Surface-Secondary-light-Normal); background: var(--Base-Surface-Secondary-light-Normal);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: var(--Spacing-x-half);
} }
.perNight { .perNight {

View File

@@ -1,13 +1,18 @@
"use client" "use client"
import { useParams } from "next/navigation"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { Lang } from "@/constants/languages"
import { selectRate } from "@/constants/routes/hotelReservation"
import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data" import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data"
import { CloseLargeIcon } from "@/components/Icons" import { CloseLargeIcon } from "@/components/Icons"
import TripAdvisorIcon from "@/components/Icons/TripAdvisor" import TripAdvisorIcon from "@/components/Icons/TripAdvisor"
import Image from "@/components/Image" import Image from "@/components/Image"
import Button from "@/components/TempDesignSystem/Button" import Button from "@/components/TempDesignSystem/Button"
import Chip from "@/components/TempDesignSystem/Chip" import Chip from "@/components/TempDesignSystem/Chip"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body" import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption" import Caption from "@/components/TempDesignSystem/Text/Caption"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
@@ -17,13 +22,15 @@ import styles from "./hotelCardDialog.module.css"
import type { HotelCardDialogProps } from "@/types/components/hotelReservation/selectHotel/map" import type { HotelCardDialogProps } from "@/types/components/hotelReservation/selectHotel/map"
export default function HotelCardDialog({ export default function HotelCardDialog({
pin, data,
isOpen, isOpen,
handleClose, handleClose,
}: HotelCardDialogProps) { }: HotelCardDialogProps) {
const params = useParams()
const lang = params.lang as Lang
const intl = useIntl() const intl = useIntl()
if (!pin) { if (!data) {
return null return null
} }
@@ -35,7 +42,7 @@ export default function HotelCardDialog({
amenities, amenities,
images, images,
ratings, ratings,
} = pin } = data
const firstImage = images[0]?.imageSizes?.small const firstImage = images[0]?.imageSizes?.small
const altText = images[0]?.metaData?.altText const altText = images[0]?.metaData?.altText
@@ -52,20 +59,24 @@ export default function HotelCardDialog({
<div className={styles.imageContainer}> <div className={styles.imageContainer}>
<Image src={firstImage} alt={altText} fill /> <Image src={firstImage} alt={altText} fill />
<div className={styles.tripAdvisor}> <div className={styles.tripAdvisor}>
<Chip intent="primary" className={styles.tripAdvisor}> <Chip intent="secondary" className={styles.tripAdvisor}>
<TripAdvisorIcon color="white" /> <TripAdvisorIcon color="burgundy" />
{ratings} {ratings}
</Chip> </Chip>
</div> </div>
</div> </div>
<div className={styles.content}> <div className={styles.content}>
<Body textTransform="bold">{name}</Body> <div className={styles.name}>
<Body textTransform="bold">{name}</Body>
</div>
<div className={styles.facilities}> <div className={styles.facilities}>
{amenities.map((facility) => { {amenities.map((facility) => {
const IconComponent = mapFacilityToIcon(facility.id) const IconComponent = mapFacilityToIcon(facility.id)
return ( return (
<div className={styles.facilitiesItem} key={facility.id}> <div className={styles.facilitiesItem} key={facility.id}>
{IconComponent && <IconComponent color="grey80" />} {IconComponent && (
<IconComponent width={16} height={16} color="grey80" />
)}
<Caption color="uiTextMediumContrast"> <Caption color="uiTextMediumContrast">
{facility.name} {facility.name}
</Caption> </Caption>
@@ -90,8 +101,15 @@ export default function HotelCardDialog({
</Subtitle> </Subtitle>
)} )}
</div> </div>
<Button size="small" theme="base" className={styles.button}>
{intl.formatMessage({ id: "See rooms" })} <Button asChild theme="base" size="small" className={styles.button}>
<Link
href={`${selectRate[lang]}?hotel=${data.operaId}`}
color="none"
keepSearchParams
>
{intl.formatMessage({ id: "See rooms" })}
</Link>
</Button> </Button>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,88 @@
"use client"
import { useCallback, useEffect, useRef } from "react"
import HotelCardDialog from "../HotelCardDialog"
import { getHotelPins } from "./utils"
import type { HotelCardDialogListingProps } from "@/types/components/hotelReservation/selectHotel/map"
export default function HotelCardDialogListing({
hotels,
activeCard,
onActiveCardChange,
}: HotelCardDialogListingProps) {
const hotelsPinData = getHotelPins(hotels)
const activeCardRef = useRef<HTMLDivElement | null>(null)
const observerRef = useRef<IntersectionObserver | null>(null)
const handleIntersection = useCallback(
(entries: IntersectionObserverEntry[]) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const cardName = entry.target.getAttribute("data-name")
if (cardName) {
onActiveCardChange(cardName)
}
}
})
},
[onActiveCardChange]
)
useEffect(() => {
observerRef.current = new IntersectionObserver(handleIntersection, {
root: null,
threshold: 0.5,
})
const elements = document.querySelectorAll("[data-name]")
elements.forEach((el) => observerRef.current?.observe(el))
return () => {
elements.forEach((el) => observerRef.current?.unobserve(el))
observerRef.current?.disconnect()
}
}, [handleIntersection])
useEffect(() => {
if (activeCardRef.current) {
// Temporarily disconnect the observer
observerRef.current?.disconnect()
activeCardRef.current.scrollIntoView({
behavior: "smooth",
block: "nearest",
inline: "center",
})
// Reconnect the observer after scrolling
const elements = document.querySelectorAll("[data-name]")
setTimeout(() => {
elements.forEach((el) => observerRef.current?.observe(el))
}, 500)
}
}, [activeCard])
return (
<>
{hotelsPinData?.length &&
hotelsPinData.map((data) => {
const isActive = data.name === activeCard
return (
<div
key={data.name}
ref={isActive ? activeCardRef : null}
data-name={data.name}
>
<HotelCardDialog
data={data}
isOpen={!!activeCard}
handleClose={() => onActiveCardChange(null)}
/>
</div>
)
})}
</>
)
}

View File

@@ -0,0 +1,22 @@
import type { HotelData } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
import type { HotelPin } from "@/types/components/hotelReservation/selectHotel/map"
export function getHotelPins(hotels: HotelData[]): HotelPin[] {
return hotels.map((hotel) => ({
coordinates: {
lat: hotel.hotelData.location.latitude,
lng: hotel.hotelData.location.longitude,
},
name: hotel.hotelData.name,
publicPrice: hotel.price?.regularAmount ?? null,
memberPrice: hotel.price?.memberAmount ?? null,
currency: hotel.price?.currency || null,
images: [
hotel.hotelData.hotelContent.images,
...(hotel.hotelData.gallery?.heroImages ?? []),
],
amenities: hotel.hotelData.detailedFacilities.slice(0, 3),
ratings: hotel.hotelData.ratings?.tripAdvisor.rating ?? null,
operaId: hotel.hotelData.operaId,
}))
}

View File

@@ -2,6 +2,37 @@
display: none; display: none;
} }
.hotelListingMobile {
display: none;
align-items: flex-end;
overflow-x: auto;
position: absolute;
bottom: 0px;
left: 0;
right: 0;
z-index: 10;
height: 280px;
gap: var(--Spacing-x1);
}
.hotelListingMobile[data-open="true"] {
display: flex;
}
.hotelListingMobile dialog {
position: relative;
padding: 0;
margin: 0;
}
.hotelListingMobile > div:first-child {
margin-left: 16px;
}
.hotelListingMobile > div:last-child {
margin-right: 16px;
}
@media (min-width: 768px) { @media (min-width: 768px) {
.hotelListing { .hotelListing {
display: block; display: block;
@@ -9,4 +40,9 @@
overflow-y: auto; overflow-y: auto;
padding-top: var(--Spacing-x2); padding-top: var(--Spacing-x2);
} }
.hotelListingMobile,
.hotelListingMobile[data-open="true"] {
display: none;
}
} }

View File

@@ -1,5 +1,6 @@
"use client" "use client"
import HotelCardDialogListing from "@/components/HotelReservation/HotelCardDialogListing"
import HotelCardListing from "@/components/HotelReservation/HotelCardListing" import HotelCardListing from "@/components/HotelReservation/HotelCardListing"
import styles from "./hotelListing.module.css" import styles from "./hotelListing.module.css"
@@ -10,16 +11,25 @@ import type { HotelListingProps } from "@/types/components/hotelReservation/sele
export default function HotelListing({ export default function HotelListing({
hotels, hotels,
activeHotelPin, activeHotelPin,
onHotelCardHover, setActiveHotelPin,
}: HotelListingProps) { }: HotelListingProps) {
return ( return (
<div className={styles.hotelListing}> <>
<HotelCardListing <div className={styles.hotelListing}>
hotelData={hotels} <HotelCardListing
type={HotelCardListingTypeEnum.MapListing} hotelData={hotels}
activeCard={activeHotelPin} type={HotelCardListingTypeEnum.MapListing}
onHotelCardHover={onHotelCardHover} activeCard={activeHotelPin}
/> onHotelCardHover={setActiveHotelPin}
</div> />
</div>
<div className={styles.hotelListingMobile} data-open={!!activeHotelPin}>
<HotelCardDialogListing
hotels={hotels}
activeCard={activeHotelPin}
onActiveCardChange={setActiveHotelPin}
/>
</div>
</>
) )
} }

View File

@@ -3,6 +3,7 @@ import { APIProvider } from "@vis.gl/react-google-maps"
import { useRouter, useSearchParams } from "next/navigation" import { useRouter, useSearchParams } from "next/navigation"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { useMediaQuery } from "usehooks-ts"
import { selectHotel } from "@/constants/routes/hotelReservation" import { selectHotel } from "@/constants/routes/hotelReservation"
@@ -12,6 +13,7 @@ import Button from "@/components/TempDesignSystem/Button"
import useLang from "@/hooks/useLang" import useLang from "@/hooks/useLang"
import HotelListing from "./HotelListing" import HotelListing from "./HotelListing"
import { getCentralCoordinates } from "./utils"
import styles from "./selectHotelMap.module.css" import styles from "./selectHotelMap.module.css"
@@ -19,19 +21,33 @@ import { SelectHotelMapProps } from "@/types/components/hotelReservation/selectH
export default function SelectHotelMap({ export default function SelectHotelMap({
apiKey, apiKey,
coordinates,
hotelPins, hotelPins,
mapId, mapId,
isModal,
hotels, hotels,
}: SelectHotelMapProps) { }: SelectHotelMapProps) {
const searchParams = useSearchParams() const searchParams = useSearchParams()
const router = useRouter() const router = useRouter()
const lang = useLang() const lang = useLang()
const intl = useIntl() const intl = useIntl()
const isAboveMobile = useMediaQuery("(min-width: 768px)")
const [activeHotelPin, setActiveHotelPin] = useState<string | null>(null) const [activeHotelPin, setActiveHotelPin] = useState<string | null>(null)
const [showBackToTop, setShowBackToTop] = useState<boolean>(false) const [showBackToTop, setShowBackToTop] = useState<boolean>(false)
const centralCoordinates = getCentralCoordinates(hotelPins)
const coordinates = isAboveMobile
? centralCoordinates
: { ...centralCoordinates, lat: centralCoordinates.lat - 0.006 }
const selectHotelParams = new URLSearchParams(searchParams.toString())
const selectedHotel = selectHotelParams.get("selectedHotel")
useEffect(() => {
if (selectedHotel) {
setActiveHotelPin(selectedHotel)
}
}, [selectedHotel])
useEffect(() => { useEffect(() => {
const hotelListingElement = document.querySelector( const hotelListingElement = document.querySelector(
`.${styles.listingContainer}` `.${styles.listingContainer}`
@@ -54,10 +70,6 @@ export default function SelectHotelMap({
hotelListingElement?.scrollTo({ top: 0, behavior: "smooth" }) hotelListingElement?.scrollTo({ top: 0, behavior: "smooth" })
} }
function handleModalDismiss() {
router.back()
}
function handlePageRedirect() { function handlePageRedirect() {
router.push(`${selectHotel[lang]}?${searchParams.toString()}`) router.push(`${selectHotel[lang]}?${searchParams.toString()}`)
} }
@@ -68,7 +80,7 @@ export default function SelectHotelMap({
size="small" size="small"
theme="base" theme="base"
className={styles.closeButton} className={styles.closeButton}
onClick={isModal ? handleModalDismiss : handlePageRedirect} onClick={handlePageRedirect}
> >
<CloseIcon color="burgundy" /> <CloseIcon color="burgundy" />
{intl.formatMessage({ id: "Close the map" })} {intl.formatMessage({ id: "Close the map" })}
@@ -84,7 +96,7 @@ export default function SelectHotelMap({
size="small" size="small"
variant="icon" variant="icon"
wrapping wrapping
onClick={isModal ? handleModalDismiss : handlePageRedirect} onClick={handlePageRedirect}
className={styles.filterContainerCloseButton} className={styles.filterContainerCloseButton}
> >
<CloseLargeIcon /> <CloseLargeIcon />
@@ -95,7 +107,7 @@ export default function SelectHotelMap({
<HotelListing <HotelListing
hotels={hotels} hotels={hotels}
activeHotelPin={activeHotelPin} activeHotelPin={activeHotelPin}
onHotelCardHover={setActiveHotelPin} setActiveHotelPin={setActiveHotelPin}
/> />
{showBackToTop && ( {showBackToTop && (
<Button <Button

View File

@@ -0,0 +1,17 @@
import { HotelPin } from "@/types/components/hotelReservation/selectHotel/map"
export function getCentralCoordinates(hotels: HotelPin[]) {
const centralCoordinates = hotels.reduce(
(acc, pin) => {
acc.lat += pin.coordinates.lat
acc.lng += pin.coordinates.lng
return acc
},
{ lat: 0, lng: 0 }
)
centralCoordinates.lat /= hotels.length
centralCoordinates.lng /= hotels.length
return centralCoordinates
}

View File

@@ -8,6 +8,10 @@
min-width: 109px !important; /* Overwriting the default width of the @vis.gl/react-google-maps AdvancedMarker */ min-width: 109px !important; /* Overwriting the default width of the @vis.gl/react-google-maps AdvancedMarker */
} }
.dialogContainer {
display: none;
}
.pin { .pin {
position: absolute; position: absolute;
top: 0; top: 0;
@@ -67,3 +71,9 @@
.card.active { .card.active {
display: block; display: block;
} }
@media (min-width: 768px) {
.dialogContainer {
display: block;
}
}

View File

@@ -50,17 +50,18 @@ export default function HotelListingMapContent({
) )
} }
> >
<HotelCardDialog <div className={styles.dialogContainer}>
isOpen={isActiveOrHovered} <HotelCardDialog
handleClose={(event: { stopPropagation: () => void }) => { isOpen={isActiveOrHovered}
event.stopPropagation() handleClose={(event: { stopPropagation: () => void }) => {
if (activeHotelPin === pin.name) { event.stopPropagation()
toggleActiveHotelPin(null) if (activeHotelPin === pin.name) {
} toggleActiveHotelPin(null)
}} }
pin={pin} }}
/> data={pin}
/>
</div>
<span <span
className={`${styles.pin} ${isActiveOrHovered ? styles.active : ""}`} className={`${styles.pin} ${isActiveOrHovered ? styles.active : ""}`}
> >

View File

@@ -12,3 +12,8 @@ div.chip {
background-color: var(--Scandic-Red-90); background-color: var(--Scandic-Red-90);
color: var(--Primary-Dark-On-Surface-Accent); color: var(--Primary-Dark-On-Surface-Accent);
} }
.secondary {
background-color: var(--Base-Surface-Primary-light-Normal);
color: var(--Primary-Light-On-Surface-Text);
}

View File

@@ -6,6 +6,7 @@ export const chipVariants = cva(styles.chip, {
variants: { variants: {
intent: { intent: {
primary: styles.primary, primary: styles.primary,
secondary: styles.secondary,
}, },
variant: { variant: {
default: styles.default, default: styles.default,

View File

@@ -1,21 +0,0 @@
import { useEffect, useState } from "react"
function useMediaQuery(query: string) {
const [isMatch, setIsMatch] = useState(false)
useEffect(() => {
const media = window.matchMedia(query)
if (media.matches !== isMatch) {
setIsMatch(media.matches)
}
const listener = () => setIsMatch(media.matches)
media.addEventListener("change", listener)
return () => media.removeEventListener("change", listener)
}, [isMatch, query])
return isMatch
}
export default useMediaQuery

16
package-lock.json generated
View File

@@ -53,6 +53,7 @@
"server-only": "^0.0.1", "server-only": "^0.0.1",
"sonner": "^1.5.0", "sonner": "^1.5.0",
"superjson": "^2.2.1", "superjson": "^2.2.1",
"usehooks-ts": "3.1.0",
"zod": "^3.22.4", "zod": "^3.22.4",
"zustand": "^4.5.2" "zustand": "^4.5.2"
}, },
@@ -14703,7 +14704,6 @@
"version": "4.0.8", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
"integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/lodash.isempty": { "node_modules/lodash.isempty": {
@@ -19454,6 +19454,20 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0" "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
} }
}, },
"node_modules/usehooks-ts": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-3.1.0.tgz",
"integrity": "sha512-bBIa7yUyPhE1BCc0GmR96VU/15l/9gP1Ch5mYdLcFBaFGQsdmXkvjV0TtOqW1yUd6VjIwDunm+flSciCQXujiw==",
"dependencies": {
"lodash.debounce": "^4.0.8"
},
"engines": {
"node": ">=16.15.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17 || ^18"
}
},
"node_modules/util-deprecate": { "node_modules/util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",

View File

@@ -68,6 +68,7 @@
"server-only": "^0.0.1", "server-only": "^0.0.1",
"sonner": "^1.5.0", "sonner": "^1.5.0",
"superjson": "^2.2.1", "superjson": "^2.2.1",
"usehooks-ts": "3.1.0",
"zod": "^3.22.4", "zod": "^3.22.4",
"zustand": "^4.5.2" "zustand": "^4.5.2"
}, },

View File

@@ -13,15 +13,13 @@ import type { Coordinates } from "@/types/components/maps/coordinates"
export interface HotelListingProps { export interface HotelListingProps {
hotels: HotelData[] hotels: HotelData[]
activeHotelPin?: string | null activeHotelPin?: string | null
onHotelCardHover?: (hotelName: string | null) => void setActiveHotelPin: (hotelName: string | null) => void
} }
export interface SelectHotelMapProps { export interface SelectHotelMapProps {
apiKey: string apiKey: string
coordinates: Coordinates
hotelPins: HotelPin[] hotelPins: HotelPin[]
mapId: string mapId: string
isModal: boolean
hotels: HotelData[] hotels: HotelData[]
} }
@@ -40,6 +38,7 @@ export type HotelPin = {
}[] }[]
amenities: Filter[] amenities: Filter[]
ratings: number | null ratings: number | null
operaId: string
} }
export interface HotelListingMapContentProps { export interface HotelListingMapContentProps {
@@ -50,6 +49,12 @@ export interface HotelListingMapContentProps {
export interface HotelCardDialogProps { export interface HotelCardDialogProps {
isOpen: boolean isOpen: boolean
pin: HotelPin data: HotelPin
handleClose: (event: { stopPropagation: () => void }) => void handleClose: (event: { stopPropagation: () => void }) => void
} }
export interface HotelCardDialogListingProps {
hotels: HotelData[]
activeCard: string | null | undefined
onActiveCardChange: (hotelName: string | null) => void
}