feat(BOOK-131): add no availability tracking * feat(BOOK-131): add no availability tracking * feat(BOOK-131): add no availability tracking * feat(BOOK-131): extract noAvailability function * feat(BOOK-131): fix every render problem * feat(BOOK-131): noavailability handle return in function Approved-by: Erik Tiekstra Approved-by: Joakim Jäderberg
94 lines
2.9 KiB
TypeScript
94 lines
2.9 KiB
TypeScript
import { cookies } from "next/headers"
|
|
|
|
import { FamilyAndFriendsCodes } from "@scandic-hotels/common/constants/familyAndFriends"
|
|
import { dt } from "@scandic-hotels/common/dt"
|
|
import { hasOverlappingDates } from "@scandic-hotels/common/dt/utils/hasOverlappingDates"
|
|
import { HotelInfoCard } from "@scandic-hotels/design-system/HotelInfoCard"
|
|
|
|
import { mapApiImagesToGalleryImages } from "../../misc/imageGallery"
|
|
import FnFNotAllowedAlert from "../FnFNotAllowedAlert"
|
|
import { HotelDetailsSidePeek } from "../HotelDetailsSidePeek"
|
|
import { AmenitiesSidePeekLabel } from "./AmenititesSidePeekLabel"
|
|
import AvailabilityError from "./AvailabilityError"
|
|
import { RoomsContainer } from "./RoomsContainer"
|
|
|
|
import type { RouterOutput } from "@scandic-hotels/trpc/client"
|
|
|
|
import type { SelectRateBooking } from "../../types/components/selectRate/selectRate"
|
|
|
|
export { SelectRateSkeleton } from "./SelectRateSkeleton"
|
|
|
|
export async function SelectRate({
|
|
booking,
|
|
hotelData,
|
|
}: {
|
|
hotelData: NonNullable<RouterOutput["hotel"]["get"]>
|
|
booking: SelectRateBooking
|
|
}) {
|
|
const bookingCode = booking.bookingCode
|
|
|
|
let isInValidFNF = false
|
|
if (bookingCode && FamilyAndFriendsCodes.includes(bookingCode)) {
|
|
const cookieStore = await cookies()
|
|
isInValidFNF = cookieStore.get("sc")?.value !== "1"
|
|
}
|
|
|
|
const validAlerts = hotelData.hotel.specialAlerts.filter((alert) =>
|
|
hasOverlappingDates(alert, dt(booking.fromDate), dt(booking.toDate))
|
|
)
|
|
|
|
return (
|
|
<>
|
|
<HotelInfoCard
|
|
hotel={{
|
|
id: hotelData.hotel.id,
|
|
name: hotelData.hotel.name,
|
|
url: hotelData.url,
|
|
ratings: hotelData.hotel.ratings,
|
|
}}
|
|
address={{
|
|
streetAddress: hotelData.hotel.address.streetAddress,
|
|
city: hotelData.hotel.address.city,
|
|
kilometersToCentre: hotelData.hotel.location.distanceToCentre / 1000,
|
|
}}
|
|
galleryImages={mapApiImagesToGalleryImages(
|
|
hotelData.hotel.galleryImages
|
|
)}
|
|
description={
|
|
hotelData.hotel.hotelContent.texts.descriptions?.medium ?? ""
|
|
}
|
|
alerts={validAlerts.map((alert) => ({
|
|
...alert,
|
|
heading: alert.heading ?? "",
|
|
text: alert.text ?? "",
|
|
}))}
|
|
facilities={hotelData.hotel.detailedFacilities}
|
|
slot={
|
|
<HotelDetailsSidePeek
|
|
hotel={{
|
|
...hotelData.hotel,
|
|
url: hotelData.url,
|
|
}}
|
|
restaurants={hotelData.restaurants}
|
|
additionalHotelData={hotelData.additionalData}
|
|
triggerLabel={<AmenitiesSidePeekLabel />}
|
|
buttonVariant="primary"
|
|
/>
|
|
}
|
|
/>
|
|
|
|
{isInValidFNF ? (
|
|
<FnFNotAllowedAlert />
|
|
) : (
|
|
<RoomsContainer
|
|
hotelType={hotelData.hotel.hotelType}
|
|
roomCategories={hotelData.roomCategories}
|
|
vat={hotelData.hotel.vat}
|
|
/>
|
|
)}
|
|
|
|
<AvailabilityError booking={booking} />
|
|
</>
|
|
)
|
|
}
|