Feat/SW-1889 * fix: remove download invoice from confirmation page * feat: remove EnterDetails Accordions Approved-by: Simon.Emanuelsson
94 lines
2.7 KiB
TypeScript
94 lines
2.7 KiB
TypeScript
"use client"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { useEnterDetailsStore } from "@/stores/enter-details"
|
|
|
|
import BedType from "@/components/HotelReservation/EnterDetails/BedType"
|
|
import Breakfast from "@/components/HotelReservation/EnterDetails/Breakfast"
|
|
import Details from "@/components/HotelReservation/EnterDetails/Details/Multiroom"
|
|
import Header from "@/components/HotelReservation/EnterDetails/Room/Header"
|
|
import Section from "@/components/HotelReservation/EnterDetails/Section"
|
|
import SelectedRoom from "@/components/HotelReservation/EnterDetails/SelectedRoom"
|
|
import Title from "@/components/TempDesignSystem/Text/Title"
|
|
import { useRoomContext } from "@/contexts/Details/Room"
|
|
|
|
import { StepEnum } from "@/types/enums/step"
|
|
|
|
export default function Multiroom() {
|
|
const intl = useIntl()
|
|
const { idx, room, roomNr, steps } = useRoomContext()
|
|
const { breakfastPackages, rooms } = useEnterDetailsStore((state) => ({
|
|
breakfastPackages: state.breakfastPackages,
|
|
rooms: state.rooms,
|
|
}))
|
|
|
|
const showBreakfastStep =
|
|
!room.breakfastIncluded && !!breakfastPackages?.length
|
|
|
|
const arePreviousRoomsValid = rooms.slice(0, idx).every((r) => r.isComplete)
|
|
|
|
const isBreakfastStepValid = showBreakfastStep
|
|
? steps[StepEnum.breakfast]?.isValid
|
|
: true
|
|
|
|
const isBreakfastDisabled = !(
|
|
arePreviousRoomsValid && steps[StepEnum.selectBed].isValid
|
|
)
|
|
|
|
const isDetailsDisabled = !(
|
|
arePreviousRoomsValid &&
|
|
steps[StepEnum.selectBed].isValid &&
|
|
isBreakfastStepValid
|
|
)
|
|
|
|
return (
|
|
<section>
|
|
<Header>
|
|
<Title level="h2" as="h4">
|
|
{intl.formatMessage(
|
|
{ id: "Room {roomIndex}" },
|
|
{
|
|
roomIndex: roomNr,
|
|
}
|
|
)}
|
|
</Title>
|
|
</Header>
|
|
|
|
<SelectedRoom />
|
|
|
|
{room.bedTypes ? (
|
|
<Section
|
|
header={intl.formatMessage({ id: "Select bed" })}
|
|
label={intl.formatMessage({ id: "Request bedtype" })}
|
|
step={StepEnum.selectBed}
|
|
disabled={!arePreviousRoomsValid}
|
|
>
|
|
<BedType />
|
|
</Section>
|
|
) : null}
|
|
|
|
{showBreakfastStep ? (
|
|
<Section
|
|
header={intl.formatMessage({ id: "Food options" })}
|
|
label={intl.formatMessage({
|
|
id: "Select breakfast options",
|
|
})}
|
|
step={StepEnum.breakfast}
|
|
disabled={isBreakfastDisabled}
|
|
>
|
|
<Breakfast />
|
|
</Section>
|
|
) : null}
|
|
|
|
<Section
|
|
header={intl.formatMessage({ id: "Details" })}
|
|
step={StepEnum.details}
|
|
label={intl.formatMessage({ id: "Enter your details" })}
|
|
disabled={isDetailsDisabled}
|
|
>
|
|
<Details />
|
|
</Section>
|
|
</section>
|
|
)
|
|
}
|