Merged in feature/SW-3572-hotel-data-endpoint (pull request #3051)

SW-3572 API route for listing hotels per city or country

* wip hotel data endpoint

* Correct route params type

* wip

* skip static paths call

* timeout when getting destinations take too long

* call noStore when we get a timeout

* add cache-control headers

* .

* .

* .

* wip

* wip

* wip

* wip

* add route for getting hotels per country

* include city when listing by country

* fix distance SI unit

* fix sorting

* Merge branch 'master' of bitbucket.org:scandic-swap/web into feature/SW-3572-hotel-data-endpoint

* packages/tracking passWithNoTests

* revalidate must be static value

* remove oxc reference

* cleanup

* cleanup hotel api route

* feat(SW-3572): cleanup error handling


Approved-by: Anton Gunnarsson
This commit is contained in:
Joakim Jäderberg
2025-11-03 12:10:22 +00:00
parent e8626d56af
commit 15a2da333d
25 changed files with 1227 additions and 249 deletions

View File

@@ -2,6 +2,7 @@ import { safeTry } from "@scandic-hotels/common/utils/safeTry"
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
import {
type HotelLocation,
isCityLocation,
isHotelLocation,
type Location,
} from "@scandic-hotels/trpc/types/locations"
@@ -37,12 +38,9 @@ export async function getHotelSearchDetails(params: {
}
const hotel = params.hotelId
? ((locations.find(
(location) =>
isHotelLocation(location) &&
"operaId" in location &&
location.operaId === params.hotelId
) as HotelLocation | undefined) ?? null)
? (locations
.filter(isHotelLocation)
.find((location) => location.operaId === params.hotelId) ?? null)
: null
if (params.isAlternativeHotels && !hotel) {
@@ -54,12 +52,13 @@ export async function getHotelSearchDetails(params: {
: params.city
const city = cityIdentifier
? (locations.find(
(location) =>
"cityIdentifier" in location &&
location.cityIdentifier?.toLowerCase() ===
? (locations
.filter(isCityLocation)
.find(
(location) =>
location.cityIdentifier?.toLowerCase() ===
cityIdentifier.toLowerCase()
) ?? null)
) ?? null)
: null
if (!city && !hotel) return null