feat(BOOK-512): Added default heading from CS to destination pages

Approved-by: Bianca Widstam
This commit is contained in:
Erik Tiekstra
2025-11-12 07:06:14 +00:00
parent 94ac475d5e
commit a96497f7c9
6 changed files with 17 additions and 49 deletions

View File

@@ -15,21 +15,19 @@ import HotelList from "./HotelList"
import styles from "./cityMap.module.css" import styles from "./cityMap.module.css"
import type { CityLocation } from "@scandic-hotels/trpc/types/locations"
import type { MapLocation } from "@/types/components/mapLocation" import type { MapLocation } from "@/types/components/mapLocation"
interface CityMapProps { interface CityMapProps {
mapId: string mapId: string
apiKey: string apiKey: string
city: CityLocation defaultHeading: string
defaultLocation: MapLocation defaultLocation: MapLocation
} }
export default function CityMap({ export default function CityMap({
mapId, mapId,
apiKey, apiKey,
city, defaultHeading,
defaultLocation, defaultLocation,
}: CityMapProps) { }: CityMapProps) {
const intl = useIntl() const intl = useIntl()
@@ -78,7 +76,7 @@ export default function CityMap({
) : null} ) : null}
<Typography variant="Title/sm"> <Typography variant="Title/sm">
<h1 className={styles.title}> <h1 className={styles.title}>
{getHeadingText(intl, city.name, "city", activeSeoFilter)} {getHeadingText(defaultHeading, activeSeoFilter)}
</h1> </h1>
</Typography> </Typography>
</div> </div>

View File

@@ -57,6 +57,7 @@ export default async function DestinationCityPage({
const { const {
blocks, blocks,
images, images,
heading,
preamble, preamble,
experiences, experiences,
has_sidepeek, has_sidepeek,
@@ -115,7 +116,7 @@ export default async function DestinationCityPage({
<CityMap <CityMap
mapId={env.GOOGLE_DYNAMIC_MAP_ID} mapId={env.GOOGLE_DYNAMIC_MAP_ID}
apiKey={env.GOOGLE_STATIC_MAP_KEY} apiKey={env.GOOGLE_STATIC_MAP_KEY}
city={city} defaultHeading={heading}
defaultLocation={destination_settings.location} defaultLocation={destination_settings.location}
/> />
) : ( ) : (
@@ -135,9 +136,8 @@ export default async function DestinationCityPage({
</main> </main>
<aside className={styles.sidebar}> <aside className={styles.sidebar}>
<SidebarContentWrapper <SidebarContentWrapper
defaultHeading={heading}
defaultPreamble={preamble} defaultPreamble={preamble}
location={city.name}
pageType="city"
> >
<ExperienceList experiences={experiences} /> <ExperienceList experiences={experiences} />
{has_sidepeek && sidepeek_content ? ( {has_sidepeek && sidepeek_content ? (

View File

@@ -1,7 +1,5 @@
"use client" "use client"
import { useIntl } from "react-intl"
import { Typography } from "@scandic-hotels/design-system/Typography" import { Typography } from "@scandic-hotels/design-system/Typography"
import { useDestinationDataStore } from "@/stores/destination-data" import { useDestinationDataStore } from "@/stores/destination-data"
@@ -17,17 +15,16 @@ import type { MapLocation } from "@/types/components/mapLocation"
interface CountryMapProps { interface CountryMapProps {
mapId: string mapId: string
apiKey: string apiKey: string
country: string defaultHeading: string
defaultLocation: MapLocation defaultLocation: MapLocation
} }
export default function CountryMap({ export default function CountryMap({
mapId, mapId,
apiKey, apiKey,
country, defaultHeading,
defaultLocation, defaultLocation,
}: CountryMapProps) { }: CountryMapProps) {
const intl = useIntl()
const { activeCities, activeSeoFilter } = useDestinationDataStore( const { activeCities, activeSeoFilter } = useDestinationDataStore(
(state) => ({ (state) => ({
activeCities: state.activeCities, activeCities: state.activeCities,
@@ -44,7 +41,7 @@ export default function CountryMap({
> >
<Typography variant="Title/sm"> <Typography variant="Title/sm">
<h1 className={styles.title}> <h1 className={styles.title}>
{getHeadingText(intl, country, "country", activeSeoFilter)} {getHeadingText(defaultHeading, activeSeoFilter)}
</h1> </h1>
</Typography> </Typography>
<CityList /> <CityList />

View File

@@ -58,6 +58,7 @@ export default async function DestinationCountryPage({
const { const {
blocks, blocks,
images, images,
heading,
preamble, preamble,
experiences, experiences,
has_sidepeek, has_sidepeek,
@@ -127,7 +128,7 @@ export default async function DestinationCountryPage({
<CountryMap <CountryMap
mapId={env.GOOGLE_DYNAMIC_MAP_ID} mapId={env.GOOGLE_DYNAMIC_MAP_ID}
apiKey={env.GOOGLE_STATIC_MAP_KEY} apiKey={env.GOOGLE_STATIC_MAP_KEY}
country={translatedCountry} defaultHeading={heading}
defaultLocation={destination_settings.location} defaultLocation={destination_settings.location}
/> />
) : ( ) : (
@@ -150,9 +151,8 @@ export default async function DestinationCountryPage({
</main> </main>
<aside className={styles.sidebar}> <aside className={styles.sidebar}>
<SidebarContentWrapper <SidebarContentWrapper
defaultHeading={heading}
defaultPreamble={preamble} defaultPreamble={preamble}
location={translatedCountry}
pageType="country"
> >
<ExperienceList experiences={experiences} /> <ExperienceList experiences={experiences} />
{has_sidepeek && sidepeek_content ? ( {has_sidepeek && sidepeek_content ? (

View File

@@ -1,7 +1,6 @@
"use client" "use client"
import React, { useRef } from "react" import React, { useRef } from "react"
import { useIntl } from "react-intl"
import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition" import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position" import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position"
@@ -9,26 +8,20 @@ import { Typography } from "@scandic-hotels/design-system/Typography"
import { useDestinationDataStore } from "@/stores/destination-data" import { useDestinationDataStore } from "@/stores/destination-data"
import { import { getHeadingText, getPreambleText } from "../utils"
getHeadingText,
getPreambleText,
} from "@/components/ContentType/DestinationPage/utils"
import styles from "./sidebarContentWrapper.module.css" import styles from "./sidebarContentWrapper.module.css"
interface SidebarContentWrapperProps extends React.PropsWithChildren { interface SidebarContentWrapperProps extends React.PropsWithChildren {
defaultHeading: string
defaultPreamble: string defaultPreamble: string
location: string
pageType: "country" | "city"
} }
export default function SidebarContentWrapper({ export default function SidebarContentWrapper({
defaultHeading,
defaultPreamble, defaultPreamble,
location,
pageType,
children, children,
}: SidebarContentWrapperProps) { }: SidebarContentWrapperProps) {
const intl = useIntl()
const sidebarRef = useRef<HTMLDivElement>(null) const sidebarRef = useRef<HTMLDivElement>(null)
const { activeSeoFilter } = useDestinationDataStore((state) => ({ const { activeSeoFilter } = useDestinationDataStore((state) => ({
activeSeoFilter: state.activeSeoFilter, activeSeoFilter: state.activeSeoFilter,
@@ -38,7 +31,7 @@ export default function SidebarContentWrapper({
name: StickyElementNameEnum.DESTINATION_SIDEBAR, name: StickyElementNameEnum.DESTINATION_SIDEBAR,
}) })
const heading = getHeadingText(intl, location, pageType, activeSeoFilter) const heading = getHeadingText(defaultHeading, activeSeoFilter)
const preamble = getPreambleText(defaultPreamble, activeSeoFilter) const preamble = getPreambleText(defaultPreamble, activeSeoFilter)
return ( return (

View File

@@ -2,31 +2,11 @@ import type {
DestinationFilter, DestinationFilter,
DestinationFilters, DestinationFilters,
} from "@scandic-hotels/trpc/types/destinationsData" } from "@scandic-hotels/trpc/types/destinationsData"
import type { IntlShape } from "react-intl"
export function getHeadingText( export function getHeadingText(
intl: IntlShape, defaultHeading: string,
location: string,
pageType: "country" | "city",
activeSeoFilter: DestinationFilter | null activeSeoFilter: DestinationFilter | null
) { ) {
const defaultHeading =
pageType === "country"
? intl.formatMessage(
{
id: "destination.destinationsInLocation",
defaultMessage: "Destinations in {location}",
},
{ location }
)
: intl.formatMessage(
{
id: "destination.hotelsInLocation",
defaultMessage: "Hotels in {location}",
},
{ location }
)
if (activeSeoFilter?.heading) { if (activeSeoFilter?.heading) {
return activeSeoFilter.heading return activeSeoFilter.heading
} }