Merged in feat/SW-1457-city-dynamic-map (pull request #1320)

feat(SW-1457): Added map and fetching hotels by cityIdentifier

* feat(SW-1457): Added map and fetching hotels by cityIdentifier


Approved-by: Fredrik Thorsson
Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-02-12 13:02:19 +00:00
parent 019a5db549
commit 1532898c23
10 changed files with 106 additions and 88 deletions

View File

@@ -8,8 +8,7 @@ import { contentStackUidWithServiceProcedure, router } from "@/server/trpc"
import { generateTag } from "@/utils/generateTag"
import { getHotelListData } from "../../hotels/utils"
import { getHotelListDataInput } from "./input"
import { getCityByCityIdentifier } from "../../hotels/utils"
import {
destinationCityPageRefsSchema,
destinationCityPageSchema,
@@ -148,6 +147,27 @@ export const destinationCityPageQueryRouter = router({
)
return null
}
const cityIdentifier =
validatedResponse.data.destinationCityPage.destination_settings.city
const city = await getCityByCityIdentifier(cityIdentifier, serviceToken)
if (!city) {
getDestinationCityPageFailCounter.add(1, {
lang,
uid: `${uid}`,
error_type: "not_found",
error: `Couldn't find city with cityIdentifier: ${cityIdentifier}`,
})
console.error(
"contentstack.destinationCityPage not found error",
JSON.stringify({
query: { lang, uid },
error: `Couldn't find city with cityIdentifier: ${cityIdentifier}`,
})
)
return null
}
getDestinationCityPageSuccessCounter.add(1, { lang, uid: `${uid}` })
console.info(
@@ -159,18 +179,8 @@ export const destinationCityPageQueryRouter = router({
return {
...validatedResponse.data,
cityIdentifier:
validatedResponse.data.destinationCityPage.destination_settings.city,
cityIdentifier,
city,
}
}),
hotelList: contentStackUidWithServiceProcedure
.input(getHotelListDataInput)
.query(async ({ ctx, input }) => {
const { lang, serviceToken } = ctx
const { cityIdentifier } = input
const hotels = await getHotelListData(lang, serviceToken, cityIdentifier)
return hotels
}),
})