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 {
@@ -10,6 +11,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 { ChevronRightIcon } from "@/components/Icons"
import StaticMap from "@/components/Maps/StaticMap"
import Alert from "@/components/TempDesignSystem/Alert"
@@ -33,6 +35,7 @@ import styles from "./selectHotel.module.css"
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
import type { HotelData } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
import type { SelectHotelProps } from "@/types/components/hotelReservation/selectHotel/selectHotel"
import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams"
import {
TrackingChannelEnum,
type TrackingSDKHotelInfo,
@@ -41,18 +44,32 @@ import {
import { AlertTypeEnum } from "@/types/enums/alert"
export default async function SelectHotel({
city,
params,
reservationParams,
searchParams,
}: SelectHotelProps) {
const intl = await getIntl()
const getHotelSearchDetailsPromise = safeTry(
getHotelSearchDetails({
searchParams: searchParams as SelectHotelSearchParams & {
[key: string]: string
},
})
)
const [searchDetails] = await getHotelSearchDetailsPromise
if (!searchDetails) return notFound()
const {
city,
selectHotelParams,
adultsInRoom,
childrenInRoomString,
childrenInRoom,
} = reservationParams
} = searchDetails
const intl = await getIntl()
if (!city) return notFound()
const hotelsPromise = safeTry(
fetchAvailableHotels({
@@ -76,7 +93,7 @@ export default async function SelectHotel({
[]
const filterList = getFiltersFromHotels(validHotels)
const searchParams = convertObjToSearchParams(selectHotelParams)
const convertedSearchParams = convertObjToSearchParams(selectHotelParams)
const breadcrumbs = [
{
title: intl.formatMessage({ id: "Home" }),
@@ -90,7 +107,7 @@ export default async function SelectHotel({
},
{
title: intl.formatMessage({ id: "Select hotel" }),
href: `${selectHotel(params.lang)}/?${searchParams.toString()}`,
href: `${selectHotel(params.lang)}/?${convertedSearchParams}`,
uid: "select-hotel",
},
{