feat: add multiroom signup

This commit is contained in:
Simon Emanuelsson
2025-02-17 15:10:48 +01:00
parent 95917e5e4f
commit 92c5566c59
78 changed files with 2035 additions and 1545 deletions

View File

@@ -5,7 +5,7 @@ import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmat
import type { linkedReservationSchema } from "@/server/routers/booking/output"
export interface LinkedReservationSchema
extends z.output<typeof linkedReservationSchema> {}
extends z.output<typeof linkedReservationSchema> { }
export interface BookingConfirmationRoomsProps
extends Pick<BookingConfirmation, "booking"> {

View File

@@ -21,9 +21,6 @@ export type BedTypeSelection = {
}
| undefined
}
export type BedTypeProps = {
bedTypes: BedTypeSelection[]
}
export interface BedTypeFormSchema extends z.output<typeof bedTypeFormSchema> {}

View File

@@ -12,7 +12,3 @@ export interface BreakfastPackages
export interface BreakfastPackage
extends z.output<typeof breakfastPackageSchema> {}
export interface BreakfastProps {
packages: BreakfastPackages
}

View File

@@ -2,13 +2,15 @@ import type { z } from "zod"
import type { Product } from "@/types/trpc/routers/hotel/roomAvailability"
import type { SafeUser } from "@/types/user"
import type { multiroomDetailsSchema } from "@/components/HotelReservation/EnterDetails/Details/Multiroom/schema"
import type {
guestDetailsSchema,
signedInDetailsSchema,
} from "@/components/HotelReservation/EnterDetails/Details/schema"
} from "@/components/HotelReservation/EnterDetails/Details/RoomOne/schema"
import type { Price } from "../price"
export type DetailsSchema = z.output<typeof guestDetailsSchema>
export type MultiroomDetailsSchema = z.output<typeof multiroomDetailsSchema>
export type SignedInDetailsSchema = z.output<typeof signedInDetailsSchema>
export interface RoomPrice {
@@ -16,19 +18,12 @@ export interface RoomPrice {
perStay: Price
}
type MemberPrice = {
currency: string
price: number
}
export interface DetailsProps {
user: SafeUser
memberPrice?: MemberPrice
}
export type JoinScandicFriendsCardProps = {
name: string
memberPrice?: MemberPrice
name?: string
}
export type RoomRate = {

View File

@@ -1,9 +1,7 @@
import type { CreditCard, SafeUser } from "@/types/user"
import type { CreditCard } from "@/types/user"
import type { PaymentMethodEnum } from "@/constants/booking"
import type { Child } from "../selectRate/selectRate"
export interface PaymentProps {
user: SafeUser
otherPaymentOptions: PaymentMethodEnum[]
mustBeGuaranteed: boolean
supportedCards: PaymentMethodEnum[]

View File

@@ -4,10 +4,11 @@ import type { Child, SelectRateSearchParams } from "./selectRate"
export interface RoomsContainerProps {
adultArray: number[]
booking: SelectRateSearchParams
bookingCode?: string
childArray?: Child[]
fromDate: Date
hotelId: number
toDate: Date
hotelData: HotelData | null
bookingCode?: string
hotelId: number
isUserLoggedIn: boolean
toDate: Date
}

View File

@@ -4,5 +4,4 @@ export interface SectionAccordionProps {
header: string
label: string
step: StepEnum
roomIndex: number
}

View File

@@ -16,7 +16,6 @@ export type RoomsData = {
export interface SummaryProps {
isMember: boolean
breakfastIncluded: boolean
}
export interface SummaryUIProps {
@@ -28,7 +27,6 @@ export interface SummaryUIProps {
}
export interface EnterDetailsSummaryProps extends SummaryUIProps {
breakfastIncluded: boolean
rooms: RoomState[]
}

View File

@@ -0,0 +1,20 @@
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
import type { BreakfastPackage } from "@/types/components/hotelReservation/enterDetails/breakfast"
import type { DetailsSchema } from "@/types/components/hotelReservation/enterDetails/details"
import type { StepEnum } from "@/types/enums/step"
import type { RoomState } from "@/types/stores/enter-details"
export interface RoomContextValue {
actions: {
setStep: (step: StepEnum) => void
updateBedType: (data: BedTypeSchema) => void
updateBreakfast: (data: BreakfastPackage | false) => void
updateDetails: (data: DetailsSchema) => void
}
currentStep: RoomState["currentStep"]
isComplete: RoomState["isComplete"]
isActiveRoom: boolean
room: RoomState["room"]
roomNr: number
steps: RoomState["steps"]
}

View File

@@ -0,0 +1,20 @@
import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType"
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
import type { Packages } from "@/types/requests/packages"
export interface Room {
bedTypes?: BedTypeSelection[]
breakfastIncluded?: boolean
cancellationText: string
mustBeGuaranteed?: boolean
packages: Packages | null
rateDetails: string[]
roomRate: RoomRate
roomType: string
roomTypeCode: string
}
export interface RoomProviderProps extends React.PropsWithChildren {
idx: number
room: Room
}

View File

@@ -1,15 +1,12 @@
import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType"
import type { StepEnum } from "@/types/enums/step"
import type { RoomAvailability } from "@/types/trpc/routers/hotel/roomAvailability"
import type { Room } from "@/types/providers/details/room"
import type { SafeUser } from "@/types/user"
import type { RoomData } from "@/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/page"
import type { BreakfastPackages } from "../components/hotelReservation/enterDetails/breakfast"
import type { SelectRateSearchParams } from "../components/hotelReservation/selectRate/selectRate"
import type { Packages } from "../requests/packages"
export interface DetailsProviderProps extends React.PropsWithChildren {
booking: SelectRateSearchParams
showBreakfastStep: boolean
roomsData: RoomData[]
breakfastPackages: BreakfastPackages | null
rooms: Room[]
searchParamsStr: string
user: SafeUser
vat: number

View File

@@ -1,7 +1,14 @@
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
import type { BreakfastPackage } from "@/types/components/hotelReservation/enterDetails/breakfast"
import type {
BedTypeSchema,
BedTypeSelection,
} from "@/types/components/hotelReservation/enterDetails/bedType"
import type {
BreakfastPackage,
BreakfastPackages,
} from "@/types/components/hotelReservation/enterDetails/breakfast"
import type {
DetailsSchema,
MultiroomDetailsSchema,
RoomPrice,
RoomRate,
SignedInDetailsSchema,
@@ -15,57 +22,71 @@ import type {
import type { Packages } from "../requests/packages"
export interface InitialRoomData {
bedType?: BedTypeSchema // used when there is only one bedtype to preselect it
bedTypes: BedTypeSelection[]
breakfastIncluded: boolean
cancellationText: string
rateDetails: string[] | undefined
roomFeatures: Packages | null
roomRate: RoomRate
roomType: string
rateDetails: string[] | undefined
cancellationText: string
roomFeatures: Packages | null
bedType?: BedTypeSchema // used when there is only one bedtype to preselect it
roomTypeCode: string
}
export interface RoomState extends InitialRoomData {
adults: number
childrenInRoom: Child[] | undefined
bedType: BedTypeSchema | undefined
breakfast: BreakfastPackage | false | undefined
guest: DetailsSchema | SignedInDetailsSchema
roomPrice: RoomPrice
export interface RoomState {
currentStep: StepEnum | null
isComplete: boolean
room: InitialRoomData & {
adults: number
bedType: BedTypeSchema | undefined
breakfast: BreakfastPackage | false | undefined
childrenInRoom: Child[] | undefined
guest: DetailsSchema | SignedInDetailsSchema
roomPrice: RoomPrice
}
steps: {
[StepEnum.selectBed]: RoomStep
[StepEnum.breakfast]?: RoomStep
[StepEnum.details]: RoomStep
}
}
export type InitialState = {
booking: SelectRateSearchParams
vat: number
rooms: InitialRoomData[]
breakfast?: false
vat: number
}
export interface DetailsState {
actions: {
setStep: (step: StepEnum | null, roomIndex?: number) => void
setStep: (idx: number) => (step: StepEnum) => void
setIsSubmittingDisabled: (isSubmittingDisabled: boolean) => void
setTotalPrice: (totalPrice: Price) => void
toggleSummaryOpen: () => void
togglePriceDetailsModalOpen: () => void
updateBedType: (data: BedTypeSchema) => void
updateBreakfast: (data: BreakfastPackage | false) => void
updateDetails: (data: DetailsSchema) => void
updateBedType: (idx: number) => (data: BedTypeSchema) => void
updateBreakfast: (idx: number) => (data: BreakfastPackage | false) => void
updateDetails: (idx: number) => (data: DetailsSchema) => void
updateMultiroomDetails: (
idx: number
) => (data: MultiroomDetailsSchema) => void
updateSeachParamString: (searchParamString: string) => void
}
activeRoom: number
booking: SelectRateSearchParams
breakfast: BreakfastPackage | false | undefined
breakfastPackages: BreakfastPackages | null
canProceedToPayment: boolean
isSubmittingDisabled: boolean
isSummaryOpen: boolean
isPriceDetailsModalOpen: boolean
lastRoom: number
rooms: RoomState[]
totalPrice: Price
searchParamString: string
totalPrice: Price
vat: number
bookingProgress: BookingProgress
}
export type PersistedState = {
activeRoom: number
booking: SelectRateSearchParams
bookingProgress: BookingProgress
rooms: RoomState[]
}
@@ -84,9 +105,3 @@ export type RoomStatus = {
[StepEnum.details]: RoomStep
}
}
export type BookingProgress = {
currentRoomIndex: number
roomStatuses: RoomStatus[]
canProceedToPayment: boolean
}

View File

@@ -45,6 +45,7 @@ export interface RatesState {
booking: SelectRateSearchParams
filterOptions: DefaultFilterOptions[]
hotelType: string | undefined
isUserLoggedIn: boolean
packages: NonNullable<Packages>
pathname: string
petRoomPackage: NonNullable<Packages>[number] | undefined
@@ -61,6 +62,7 @@ export interface InitialState
RatesState,
| "booking"
| "hotelType"
| "isUserLoggedIn"
| "packages"
| "pathname"
| "roomCategories"
@@ -68,7 +70,6 @@ export interface InitialState
| "searchParams"
| "vat"
> {
isUserLoggedIn: boolean
labels: {
accessibilityRoom: string
allergyRoom: string