feat(SW-1446): add Jump to functionality to Destination Overview Page

This commit is contained in:
Michael Zetterberg
2025-03-19 06:56:38 +01:00
parent 85a90baa12
commit 9e84da45bc
44 changed files with 3069 additions and 1297 deletions
@@ -0,0 +1,21 @@
query GetLocationsUrls($locale: String!) {
hotels: all_hotel_page(locale: $locale) {
items {
url
id: hotel_page_id
}
}
cities: all_destination_city_page {
items {
url
id: destination_settings {
sv: city_sweden
pl: city_poland
no: city_norway
de: city_germany
fi: city_finland
da: city_denmark
}
}
}
}
@@ -1,3 +1,5 @@
import { isDefined } from "@/server/utils"
import { getLang } from "@/i18n/serverContext"
import { cache } from "@/utils/cache"
@@ -268,3 +270,79 @@ export const getPageSettingsBookingCode = cache(
export const getJobylonFeed = cache(async function getMemoizedJobylonFeed() {
return serverClient().partner.jobylon.feed.get()
})
export const getJumpToData = cache(async function getMemoizedJumpToData() {
const lang = getLang()
const [locationsResults, urlsResults] = await Promise.allSettled([
getLocations(),
serverClient().hotel.locations.urls({ lang }),
])
if (
locationsResults.status === "fulfilled" &&
urlsResults.status === "fulfilled"
) {
const locations = locationsResults.value
const urls = urlsResults.value
if (!locations || !urls) {
return null
}
return locations
.map((location) => {
const { id, name, type } = location
const isCity = type === "cities"
const isHotel = type === "hotels"
let url: string | undefined
if (isCity) {
url = urls.cities.find(
(c) =>
c.id &&
location.cityIdentifier &&
c.id === location.cityIdentifier
)?.url
} else if (isHotel) {
url = urls.hotels.find(
(h) => h.id && location.id && h.id === location.id
)?.url
}
if (!url) {
return null
}
let description = ""
if (isCity) {
description = location.country
} else if (isHotel) {
description = location.relationships.city.name
}
const rankingNames: string[] = [location.name]
if (isCity) {
if (location.cityIdentifier) {
rankingNames.push(location.cityIdentifier)
}
}
const rankingKeywords = location.keyWords || []
return {
id,
displayName: name,
type,
description,
url,
rankingNames: rankingNames.map((v) => v.toLowerCase()),
rankingKeywords: rankingKeywords.map((v) => v.toLowerCase()),
}
})
.filter(isDefined)
}
return null
})