diff --git a/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx b/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx index 188c96719..453ae989d 100644 --- a/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx +++ b/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx @@ -69,7 +69,7 @@ export function Search({ switch (selectedItem.type) { case "cities": setValue("hotel", undefined) - setValue("city", selectedItem.name) + setValue("city", selectedItem.cityIdentifier) break case "hotels": diff --git a/apps/scandic-web/server/routers/autocomplete/destinations.ts b/apps/scandic-web/server/routers/autocomplete/destinations.ts index 35d80a3c9..2ada552bb 100644 --- a/apps/scandic-web/server/routers/autocomplete/destinations.ts +++ b/apps/scandic-web/server/routers/autocomplete/destinations.ts @@ -60,7 +60,8 @@ export const getDestinationsAutoCompleteRoute = safeProtectedServiceProcedure const selectedCity = locations.find( (location) => - location.type === "cities" && location.name === input.selectedCity + location.type === "cities" && + location.cityIdentifier === input.selectedCity ) return { diff --git a/apps/scandic-web/server/routers/autocomplete/schema.ts b/apps/scandic-web/server/routers/autocomplete/schema.ts index a37e3f3aa..b32a62927 100644 --- a/apps/scandic-web/server/routers/autocomplete/schema.ts +++ b/apps/scandic-web/server/routers/autocomplete/schema.ts @@ -7,6 +7,7 @@ export const autoCompleteLocationSchema = z.object({ searchTokens: z.array(z.string()), destination: z.string(), url: z.string().optional(), + cityIdentifier: z.string().optional(), }) export type AutoCompleteLocation = z.infer diff --git a/apps/scandic-web/server/routers/autocomplete/util/filterAutoCompleteLocations.ts b/apps/scandic-web/server/routers/autocomplete/util/filterAutoCompleteLocations.ts index 9686d15d0..7f5714594 100644 --- a/apps/scandic-web/server/routers/autocomplete/util/filterAutoCompleteLocations.ts +++ b/apps/scandic-web/server/routers/autocomplete/util/filterAutoCompleteLocations.ts @@ -49,6 +49,7 @@ export function filterAutoCompleteLocations( ({ id: x.item.id, name: x.item.name, + cityIdentifier: x.item.cityIdentifier, destination: x.item.destination, searchTokens: x.item.searchTokens, type: x.item.type, diff --git a/apps/scandic-web/server/routers/autocomplete/util/mapLocationToAutoCompleteLocation.ts b/apps/scandic-web/server/routers/autocomplete/util/mapLocationToAutoCompleteLocation.ts index 2bde410be..d2d7fa330 100644 --- a/apps/scandic-web/server/routers/autocomplete/util/mapLocationToAutoCompleteLocation.ts +++ b/apps/scandic-web/server/routers/autocomplete/util/mapLocationToAutoCompleteLocation.ts @@ -18,5 +18,7 @@ export function mapLocationToAutoCompleteLocation( location.type === "hotels" ? location.relationships.city.name : location.country, + cityIdentifier: + location.type === "cities" ? location.cityIdentifier : undefined, } } diff --git a/apps/scandic-web/server/routers/hotels/output.ts b/apps/scandic-web/server/routers/hotels/output.ts index 18987dc77..6cba530f9 100644 --- a/apps/scandic-web/server/routers/hotels/output.ts +++ b/apps/scandic-web/server/routers/hotels/output.ts @@ -474,6 +474,10 @@ export const locationsSchema = z.object({ if (!node.operaId) { return false } + } else { + if (!node.cityIdentifier) { + return false + } } return true }) diff --git a/apps/scandic-web/utils/hotelSearchDetails.ts b/apps/scandic-web/utils/hotelSearchDetails.ts index 020eac72e..bdcbbe7ac 100644 --- a/apps/scandic-web/utils/hotelSearchDetails.ts +++ b/apps/scandic-web/utils/hotelSearchDetails.ts @@ -66,7 +66,9 @@ export async function getHotelSearchDetails( const city = cityName ? (locations.find( - (location) => location.name.toLowerCase() === cityName.toLowerCase() + (location) => + "cityIdentifier" in location && + location.cityIdentifier?.toLowerCase() === cityName.toLowerCase() ) ?? null) : null