From 5beffe496860b52a7a386289885b4063f4123e6d Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Mon, 28 Apr 2025 09:12:17 +0000 Subject: [PATCH] feat(SW-1780): Hotel address now leads to map view with hotel active MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Approved-by: Michael Zetterberg Approved-by: Matilda Landström --- .../components/ButtonLink/index.tsx | 3 +- .../HotelListItem/hotelListItem.module.css | 22 ++- .../CityMap/HotelListItem/index.tsx | 116 ++++++++------ .../hotelListingItem.module.css | 18 ++- .../HotelListing/HotelListingItem/index.tsx | 151 ++++++++++-------- .../server/routers/hotels/utils.ts | 4 +- 6 files changed, 189 insertions(+), 125 deletions(-) diff --git a/apps/scandic-web/components/ButtonLink/index.tsx b/apps/scandic-web/components/ButtonLink/index.tsx index faddb18a1..3413e6a8a 100644 --- a/apps/scandic-web/components/ButtonLink/index.tsx +++ b/apps/scandic-web/components/ButtonLink/index.tsx @@ -24,6 +24,7 @@ export default function ButtonLink({ color, size, typography, + wrapping, className, href, target, @@ -38,7 +39,7 @@ export default function ButtonLink({ variant, color, size, - + wrapping, typography, className, }) diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/hotelListItem.module.css b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/hotelListItem.module.css index b6a4321f5..ecf186cfb 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/hotelListItem.module.css +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/hotelListItem.module.css @@ -34,6 +34,11 @@ background-color: var(--Base-Surface-Primary-light-Normal); padding: var(--Spacing-x-quarter) var(--Spacing-x1); border-radius: var(--Corner-radius-Small); + color: var(--Text-Interactive-Default); +} + +.hotelName { + color: var(--Text-Default); } .intro { @@ -44,15 +49,26 @@ .captions { display: flex; gap: var(--Spacing-x1); + color: var(--Text-Tertiary); +} + +.addressButton { + background-color: transparent; + border-width: 0; + padding: 0; + color: var(--Text-Interactive-Secondary); + cursor: pointer; + + &:hover { + color: var(--Text-Interactive-Hover-Secondary); + } } .amenityList { display: flex; gap: var(--Spacing-x-one-and-half); flex-wrap: wrap; - color: var(--UI-Text-Medium-contrast); - font-family: var(--typography-Body-Regular-fontFamily); - font-size: var(--typography-Caption-Underline-fontSize); + color: var(--Text-Secondary); } .amenityItem { diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/index.tsx index a5f706854..a4715ed85 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelListItem/index.tsx @@ -1,20 +1,19 @@ "use client" -import Link from "next/link" import { useCallback, useEffect, useRef } from "react" +import { Button as AriaButton } from "react-aria-components" import { useIntl } from "react-intl" import HotelLogoIcon from "@scandic-hotels/design-system/Icons/HotelLogoIcon" import TripadvisorIcon from "@scandic-hotels/design-system/Icons/TripadvisorIcon" +import { Typography } from "@scandic-hotels/design-system/Typography" import { useDestinationPageHotelsMapStore } from "@/stores/destination-page-hotels-map" +import ButtonLink from "@/components/ButtonLink" import { FacilityToIcon } from "@/components/ContentType/HotelPage/data" import ImageGallery from "@/components/ImageGallery" -import Button from "@/components/TempDesignSystem/Button" import Divider from "@/components/TempDesignSystem/Divider" -import Caption from "@/components/TempDesignSystem/Text/Caption" -import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import { mapApiImagesToGalleryImages } from "@/utils/imageGallery" import { getSingleDecimal } from "@/utils/numberFormatting" @@ -27,9 +26,11 @@ export default function HotelListItem(data: DestinationPagesHotelData) { const { hotel, url } = data const galleryImages = mapApiImagesToGalleryImages(hotel.galleryImages || []) const amenities = hotel.detailedFacilities.slice(0, 5) + const address = `${hotel.address.streetAddress}, ${hotel.address.city}` const itemRef = useRef(null) - const { setHoveredMarker, activeMarker } = useDestinationPageHotelsMapStore() + const { setHoveredMarker, activeMarker, setActiveMarker } = + useDestinationPageHotelsMapStore() useEffect(() => { if (activeMarker === hotel.id) { @@ -74,10 +75,12 @@ export default function HotelListItem(data: DestinationPagesHotelData) { )} /> {hotel.tripadvisor && ( -
- - {hotel.tripadvisor} -
+ +
+ + {hotel.tripadvisor} +
+
)}
@@ -85,50 +88,63 @@ export default function HotelListItem(data: DestinationPagesHotelData) {
- -

{hotel.name}

-
-
- - {hotel.address.streetAddress} - - - - {intl.formatMessage( - { - defaultMessage: "{number} km to city center", - }, - { - number: getSingleDecimal( - hotel.location.distanceToCentre / 1000 - ), - } - )} - -
+ +

{hotel.name}

+
+ +
+ + setActiveMarker(hotel.id)} + > + {address} + + + +

+ {intl.formatMessage( + { + defaultMessage: "{number} km to city center", + }, + { + number: getSingleDecimal( + hotel.location.distanceToCentre / 1000 + ), + } + )} +

+
+
- + +
    + {amenities.map((amenity) => { + return ( +
  • + + {amenity.name} +
  • + ) + })} +
+
{url && (
- + + {intl.formatMessage({ + defaultMessage: "See hotel details", + })} +
)} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/hotelListingItem.module.css b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/hotelListingItem.module.css index a2777b6f4..d25a9049f 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/hotelListingItem.module.css +++ b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/hotelListingItem.module.css @@ -28,6 +28,11 @@ background-color: var(--Base-Surface-Primary-light-Normal); padding: var(--Spacing-x-quarter) var(--Spacing-x1); border-radius: var(--Corner-radius-Small); + color: var(--Text-Interactive-Default); +} + +.hotelName { + color: var(--Text-Default); } .intro { @@ -38,15 +43,22 @@ .captions { display: flex; gap: var(--Spacing-x1); + color: var(--Text-Tertiary); +} + +.addressLink { + color: var(--Text-Interactive-Secondary); + + &:hover { + color: var(--Text-Interactive-Hover-Secondary); + } } .amenityList { display: flex; gap: var(--Spacing-x-one-and-half); flex-wrap: wrap; - color: var(--UI-Text-Medium-contrast); - font-family: var(--typography-Body-Regular-fontFamily); - font-size: var(--typography-Caption-Underline-fontSize); + color: var(--Text-Secondary); } .amenityItem { diff --git a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/index.tsx index 3e961c8cf..68354af37 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/HotelListing/HotelListingItem/index.tsx @@ -1,6 +1,6 @@ "use client" -import Link from "next/link" +import NextLink from "next/link" import { useParams } from "next/navigation" import { useEffect, useState } from "react" import { useIntl } from "react-intl" @@ -12,12 +12,10 @@ import { Typography } from "@scandic-hotels/design-system/Typography" import { useDestinationPageHotelsMapStore } from "@/stores/destination-page-hotels-map" +import ButtonLink from "@/components/ButtonLink" import { FacilityToIcon } from "@/components/ContentType/HotelPage/data" import ImageGallery from "@/components/ImageGallery" -import Button from "@/components/TempDesignSystem/Button" import Divider from "@/components/TempDesignSystem/Divider" -import Caption from "@/components/TempDesignSystem/Text/Caption" -import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import { mapApiImagesToGalleryImages } from "@/utils/imageGallery" import { getSingleDecimal } from "@/utils/numberFormatting" @@ -34,6 +32,8 @@ export default function HotelListingItem(data: DestinationPagesHotelData) { const amenities = hotel.detailedFacilities.slice(0, 5) const [mapUrl, setMapUrl] = useState(null) + const address = `${hotel.address.streetAddress}, ${hotel.address.city}` + useEffect(() => { const url = new URL(window.location.href) url.searchParams.set("view", "map") @@ -55,85 +55,106 @@ export default function HotelListingItem(data: DestinationPagesHotelData) { )} /> {hotel.tripadvisor && ( -
- - {hotel.tripadvisor} -
+ +
+ + {hotel.tripadvisor} +
+
)}
- -

{hotel.name}

-
-
- - {hotel.address.streetAddress} - - - - {intl.formatMessage( - { - defaultMessage: "{number} km to city center", - }, - { - number: getSingleDecimal( - hotel.location.distanceToCentre / 1000 - ), - } - )} - -
+ +

{hotel.name}

+
+ +
+ {mapUrl ? ( + <> + + setActiveMarker(hotel.id)} + href={mapUrl} + className={styles.addressLink} + aria-label={intl.formatMessage({ + defaultMessage: "See on map", + })} + > + {address} + + + + + ) : null} +

+ {intl.formatMessage( + { + defaultMessage: "{number} km to city center", + }, + { + number: getSingleDecimal( + hotel.location.distanceToCentre / 1000 + ), + } + )} +

+
+
{hotel.hotelDescription ? (

{hotel.hotelDescription}

) : null} -
    - {amenities.map((amenity) => { - const Icon = ( - - ) - return ( -
  • - {Icon && Icon} - {amenity.name} -
  • - ) - })} -
+ +
    + {amenities.map((amenity) => { + return ( +
  • + + {amenity.name} +
  • + ) + })} +
+
{mapUrl && ( - + setActiveMarker(hotel.id)} + > + {intl.formatMessage({ + defaultMessage: "See on map", + })} + + )} {url && ( <>
- + + {intl.formatMessage({ + defaultMessage: "See hotel details", + })} +
)} diff --git a/apps/scandic-web/server/routers/hotels/utils.ts b/apps/scandic-web/server/routers/hotels/utils.ts index 96cab68ee..0a22c90bc 100644 --- a/apps/scandic-web/server/routers/hotels/utils.ts +++ b/apps/scandic-web/server/routers/hotels/utils.ts @@ -519,9 +519,7 @@ export async function getHotelsByHotelIds({ const data: DestinationPagesHotelData = { hotel: { id: hotel.id, - galleryImages: hotel.galleryImages?.length - ? [hotel.galleryImages[0]] - : [], + galleryImages: hotel.galleryImages, name: hotel.name, tripadvisor: hotel.ratings?.tripAdvisor?.rating, detailedFacilities: hotel.detailedFacilities || [],