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

View File

@@ -3,6 +3,8 @@ import { Lang } from "@/constants/languages"
import { env } from "@/env/server"
import * as api from "@/lib/api"
import { dt } from "@/lib/dt"
import { GetLocationsUrls } from "@/lib/graphql/Query/Locations/Locations.graphql"
import { request } from "@/lib/graphql/request"
import { badRequestError, unauthorizedError } from "@/server/errors/trpc"
import {
contentStackBaseWithServiceProcedure,
@@ -16,10 +18,15 @@ import { toApiLang } from "@/server/utils"
import { generateChildrenString } from "@/components/HotelReservation/utils"
import { getCacheClient } from "@/services/dataCache"
import { cache } from "@/utils/cache"
import { removeMultipleSlashes } from "@/utils/url"
import { getHotelPageUrls } from "../contentstack/hotelPage/utils"
import { getVerifiedUser } from "../user/query"
import { additionalDataSchema } from "./schemas/hotel/include/additionalData"
import {
type GetLocationsUrlsData,
locationsUrlsSchema,
} from "./schemas/location/urls"
import { meetingRoomsSchema } from "./schemas/meetingRoom"
import {
ancillaryPackageInputSchema,
@@ -32,6 +39,7 @@ import {
getHotelsByCSFilterInput,
getHotelsByHotelIdsAvailabilityInputSchema,
getLocationsInput,
getLocationsUrlsInput,
getMeetingRoomsInputSchema,
hotelInputSchema,
hotelsAvailabilityInputSchema,
@@ -55,6 +63,11 @@ import {
roomFeaturesSchema,
roomsAvailabilitySchema,
} from "./output"
import {
locationsUrlsCounter,
locationsUrlsFailCounter,
locationsUrlsSuccessCounter,
} from "./telemetry"
import tempRatesData from "./tempRatesData.json"
import {
getCitiesByCountry,
@@ -1505,6 +1518,79 @@ export const hotelQueryRouter = router({
"max"
)
}),
urls: publicProcedure
.input(getLocationsUrlsInput)
.query(async ({ input }) => {
const procedureName = "hotels.locations.urls"
const { lang } = input
locationsUrlsCounter.add(1, { lang })
console.info(
`${procedureName}: start`,
JSON.stringify({ query: { lang } })
)
const response = await request<GetLocationsUrlsData>(
GetLocationsUrls,
{ locale: lang },
{
key: `${lang}:${procedureName}`,
ttl: "max",
}
)
if (!response.data) {
locationsUrlsFailCounter.add(1, {
lang,
error_type: "no data",
response: JSON.stringify(response),
})
console.error(`${procedureName}: no data`, {
variables: { lang },
error_type: "no data",
response,
})
return null
}
const locationsUrls = locationsUrlsSchema.safeParse(response.data)
if (!locationsUrls.success) {
locationsUrlsFailCounter.add(1, {
lang,
error_type: "validation_error",
error: JSON.stringify(locationsUrls.error),
})
console.error(`${procedureName}: validation error`, {
variables: { lang },
error_type: "validation_error",
error: locationsUrls.error,
})
return null
}
locationsUrlsSuccessCounter.add(1, { lang })
console.info(`${procedureName}: success`, {
variables: { lang },
})
const { data } = locationsUrls
data.hotels = data.hotels.map((hotel) => {
hotel.url = removeMultipleSlashes(`/${lang}/${hotel.url}`)
return hotel
})
data.cities = data.cities.map((city) => {
city.url = removeMultipleSlashes(`/${lang}/${city.url}`)
return city
})
return locationsUrls.data
}),
}),
map: router({
city: serviceProcedure