feat: keep inventory of bedselections
This commit is contained in:
committed by
Michael Zetterberg
parent
39b89c5d51
commit
5ca30d02a0
@@ -1,12 +1,8 @@
|
||||
import { cookies } from "next/headers"
|
||||
import { notFound, redirect } from "next/navigation"
|
||||
import { notFound } from "next/navigation"
|
||||
import { Suspense } from "react"
|
||||
|
||||
import {
|
||||
BookingErrorCodeEnum,
|
||||
FamilyAndFriendsCodes,
|
||||
} from "@/constants/booking"
|
||||
import { selectRate } from "@/constants/routes/hotelReservation"
|
||||
import { FamilyAndFriendsCodes } from "@/constants/booking"
|
||||
import {
|
||||
getBreakfastPackages,
|
||||
getHotel,
|
||||
@@ -30,7 +26,6 @@ import styles from "./page.module.css"
|
||||
|
||||
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
import type { Room } from "@/types/providers/details/room"
|
||||
|
||||
export default async function DetailsPage({
|
||||
params: { lang },
|
||||
@@ -76,25 +71,11 @@ export default async function DetailsPage({
|
||||
void getBreakfastPackages(breakfastInput)
|
||||
void getProfileSafely()
|
||||
|
||||
const roomsAvailability = await getSelectedRoomsAvailabilityEnterDetails({
|
||||
const rooms = await getSelectedRoomsAvailabilityEnterDetails({
|
||||
booking,
|
||||
lang,
|
||||
})
|
||||
|
||||
const rooms: Room[] = []
|
||||
for (let room of roomsAvailability) {
|
||||
if (!room) {
|
||||
// TODO: This could be done in the route already.
|
||||
// (possibly also add an error case to url?)
|
||||
// -------------------------------------------------------
|
||||
// redirect back to select-rate if availability call fails
|
||||
selectRoomParams.set("errorCode", BookingErrorCodeEnum.AvailabilityError)
|
||||
redirect(`${selectRate(lang)}?${selectRoomParams.toString()}`)
|
||||
}
|
||||
|
||||
rooms.push(room)
|
||||
}
|
||||
|
||||
const hotelData = await getHotel(hotelInput)
|
||||
|
||||
if (!hotelData || !rooms.length) {
|
||||
|
||||
Reference in New Issue
Block a user