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:
@@ -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
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user