feat(SW-614): Add mustBeGuaranteed flag and update content based on this

This commit is contained in:
Tobias Johansson
2024-10-23 13:22:49 +02:00
parent 6523e2329b
commit a690750c36
12 changed files with 144 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ import {
getCreditCardsSafely,
getHotelData,
getProfileSafely,
getRoomAvailability,
} from "@/lib/trpc/memoizedRequests"
import BedType from "@/components/HotelReservation/EnterDetails/BedType"
@@ -21,6 +22,7 @@ import type { LangParams, PageArgs } from "@/types/params"
export function preload() {
void getProfileSafely()
void getCreditCardsSafely()
void getRoomAvailability("811", 1, "2024-11-01", "2024-11-02")
}
function isValidStep(step: string): step is StepEnum {
@@ -43,10 +45,19 @@ export default async function StepPage({
const savedCreditCards = await getCreditCardsSafely()
const breakfastPackages = await getBreakfastPackages(searchParams.hotel)
if (!isValidStep(params.step) || !hotel) {
const roomAvailability = await getRoomAvailability(
searchParams.hotel,
Number(searchParams.adults),
searchParams.checkIn,
searchParams.checkOut
)
if (!isValidStep(params.step) || !hotel || !roomAvailability) {
return notFound()
}
const mustBeGuaranteed = false
return (
<section>
<HistoryStateManager />
@@ -72,17 +83,24 @@ export default async function StepPage({
<Details user={user} />
</SectionAccordion>
<SectionAccordion
header="Payment"
header={mustBeGuaranteed ? "Payment Guarantee" : "Payment"}
step={StepEnum.payment}
label={intl.formatMessage({ id: "Select payment method" })}
label={
mustBeGuaranteed
? intl.formatMessage({ id: "Guarantee booking with credit card" })
: intl.formatMessage({ id: "Select payment method" })
}
>
<Payment
hotelId={hotel.data.attributes.operaId}
hotelId={searchParams.hotel}
otherPaymentOptions={
hotel.data.attributes.merchantInformationData
.alternatePaymentOptions
mustBeGuaranteed
? []
: hotel.data.attributes.merchantInformationData
.alternatePaymentOptions
}
savedCreditCards={savedCreditCards}
mustBeGuaranteed={mustBeGuaranteed}
/>
</SectionAccordion>
</section>