Merged in fix/SW-1103-page-loading (pull request #1181)

Fix/SW-1103 page loading

* feat(SW-1103): Move backend req behinde suspense

* fix/SW-1103 fix merge conflicts


Approved-by: Joakim Jäderberg
This commit is contained in:
Pontus Dreij
2025-01-24 10:16:30 +00:00
parent 9ff976cde1
commit 7343d873c2
8 changed files with 63 additions and 77 deletions

View File

@@ -1,4 +1,5 @@
import { differenceInCalendarDays, format, isWeekend } from "date-fns"
import { notFound } from "next/navigation"
import { Suspense } from "react"
import { env } from "@/env/server"
@@ -8,6 +9,7 @@ import {
fetchAvailableHotels,
getFiltersFromHotels,
} from "@/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils"
import { getHotelSearchDetails } from "@/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils"
import TrackingSDK from "@/components/TrackingSDK"
import { getLang } from "@/i18n/serverContext"
import { safeTry } from "@/utils/safeTry"
@@ -21,6 +23,7 @@ import type {
NullableHotelData,
} from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
import type { SelectHotelMapContainerProps } from "@/types/components/hotelReservation/selectHotel/map"
import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams"
import {
TrackingChannelEnum,
type TrackingSDKHotelInfo,
@@ -32,15 +35,32 @@ function isValidHotelData(hotel: NullableHotelData): hotel is HotelData {
}
export async function SelectHotelMapContainer({
city,
selectHotelParams,
adultsInRoom,
childrenInRoom,
childrenInRoomString,
searchParams,
}: SelectHotelMapContainerProps) {
const lang = getLang()
const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID
const googleMapsApiKey = env.GOOGLE_STATIC_MAP_KEY
const getHotelSearchDetailsPromise = safeTry(
getHotelSearchDetails({
searchParams: searchParams as SelectHotelSearchParams & {
[key: string]: string
},
})
)
const [searchDetails] = await getHotelSearchDetailsPromise
if (!searchDetails) return notFound()
const {
city,
selectHotelParams,
adultsInRoom,
childrenInRoom,
childrenInRoomString,
} = searchDetails
if (!city) return notFound()
const fetchAvailableHotelsPromise = safeTry(
fetchAvailableHotels({