fix(SW-664): Fixed issue with params when fetching data from API in relation to Hotellisting
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ApiLang } from "@/constants/languages"
|
||||
import * as api from "@/lib/api"
|
||||
import { dt } from "@/lib/dt"
|
||||
import { badRequestError } from "@/server/errors/trpc"
|
||||
@@ -79,12 +80,13 @@ export const getHotelData = cache(
|
||||
async (input: HotelDataInput, serviceToken: string) => {
|
||||
const { hotelId, language, isCardOnlyPayment } = input
|
||||
|
||||
const params: Record<string, string | string[]> = {
|
||||
const includes = ["RoomCategories", "Restaurants"] // "RoomCategories","NearbyHotels","Restaurants","City",
|
||||
const params = new URLSearchParams({
|
||||
hotelId,
|
||||
language,
|
||||
}
|
||||
})
|
||||
|
||||
params.include = ["RoomCategories", "Restaurants"] // "RoomCategories","NearbyHotels","Restaurants","City",
|
||||
includes.forEach((include) => params.append("include", include))
|
||||
|
||||
getHotelCounter.add(1, {
|
||||
hotelId,
|
||||
@@ -680,8 +682,11 @@ export const hotelQueryRouter = router({
|
||||
const { locationFilter, hotelsToInclude } = input
|
||||
|
||||
const language = ctx.lang
|
||||
const apiLang = toApiLang(language)
|
||||
const options: RequestOptionsWithOutBody = {
|
||||
cache: "force-cache",
|
||||
// needs to clear default option as only
|
||||
// cache or next.revalidate is permitted
|
||||
cache: undefined,
|
||||
headers: {
|
||||
Authorization: `Bearer ${ctx.serviceToken}`,
|
||||
},
|
||||
@@ -710,10 +715,10 @@ export const hotelQueryRouter = router({
|
||||
hotelsToFetch = hotelsToInclude
|
||||
} else if (locationFilter?.city) {
|
||||
const locationsParams = new URLSearchParams({
|
||||
language: toApiLang(ctx.lang),
|
||||
language: apiLang,
|
||||
})
|
||||
const locations = await getLocations(
|
||||
ctx.lang,
|
||||
language,
|
||||
options,
|
||||
locationsParams,
|
||||
null
|
||||
@@ -744,7 +749,7 @@ export const hotelQueryRouter = router({
|
||||
return []
|
||||
}
|
||||
const hotelIdsParams = new URLSearchParams({
|
||||
language: ctx.lang,
|
||||
language: apiLang,
|
||||
city: cityId,
|
||||
onlyBasicInfo: "true",
|
||||
})
|
||||
@@ -779,7 +784,7 @@ export const hotelQueryRouter = router({
|
||||
hotelsToFetch = filteredHotelIds
|
||||
} else if (locationFilter?.country) {
|
||||
const hotelIdsParams = new URLSearchParams({
|
||||
language: ctx.lang,
|
||||
language: ApiLang.En,
|
||||
country: locationFilter.country,
|
||||
onlyBasicInfo: "true",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user