Merged in chore/refactor-booking-flow (pull request #1333)
chore: cleaning up select-rate Approved-by: Arvid Norlin Approved-by: Linus Flood
This commit is contained in:
15
types/components/hotelReservation/enterDetails/payment.ts
Normal file
15
types/components/hotelReservation/enterDetails/payment.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { CreditCard, SafeUser } 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[]
|
||||
}
|
||||
|
||||
export interface PaymentClientProps
|
||||
extends Omit<PaymentProps, "supportedCards"> {
|
||||
savedCreditCards: CreditCard[] | null
|
||||
}
|
||||
@@ -14,17 +14,14 @@ type ProductPrice = z.output<typeof productTypePriceSchema>
|
||||
export type RoomPriceSchema = z.output<typeof priceSchema>
|
||||
|
||||
export type FlexibilityOptionProps = {
|
||||
handleSelect: (
|
||||
rateCode: string,
|
||||
rateName: string,
|
||||
paymentTerm: string
|
||||
) => void
|
||||
features: RoomConfiguration["features"]
|
||||
isSelected: boolean
|
||||
isUserLoggedIn: boolean
|
||||
paymentTerm: string
|
||||
petRoomPackage: RoomPackage | undefined
|
||||
priceInformation?: Array<string>
|
||||
product: Product | undefined
|
||||
roomType: RoomConfiguration["roomType"]
|
||||
roomTypeCode: RoomConfiguration["roomTypeCode"]
|
||||
title: string
|
||||
}
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
import type { RoomsAvailability } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { Price } from "../price"
|
||||
import type { RoomPackages } from "./roomFilter"
|
||||
import type { SelectRateSearchParams } from "./selectRate"
|
||||
|
||||
export interface RateSummaryProps {
|
||||
isUserLoggedIn: boolean
|
||||
packages: RoomPackages | undefined
|
||||
roomsAvailability: RoomsAvailability
|
||||
booking: SelectRateSearchParams
|
||||
vat: number
|
||||
}
|
||||
|
||||
export interface MobileSummaryProps {
|
||||
totalPriceToShow: Price
|
||||
export interface MobileSummaryProps extends RateSummaryProps {
|
||||
isAllRoomsSelected: boolean
|
||||
booking: SelectRateSearchParams
|
||||
isUserLoggedIn: boolean
|
||||
vat: number
|
||||
roomsAvailability: RoomsAvailability
|
||||
totalPriceToShow: Price
|
||||
}
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
import type { z } from "zod"
|
||||
|
||||
import type { Room } from "@/types/hotel"
|
||||
import type {
|
||||
RateDefinition,
|
||||
RoomConfiguration,
|
||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { RoomConfiguration } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { packagePriceSchema } from "@/server/routers/hotels/schemas/packages"
|
||||
import type { RoomPriceSchema } from "./flexibilityOption"
|
||||
import type { RoomPackageCodes, RoomPackages } from "./roomFilter"
|
||||
|
||||
export type RoomCardProps = {
|
||||
hotelId: string
|
||||
hotelType: string | undefined
|
||||
roomConfiguration: RoomConfiguration
|
||||
rateDefinitions: RateDefinition[]
|
||||
roomCategories: Room[]
|
||||
selectedPackages: RoomPackageCodes[]
|
||||
roomListIndex: number
|
||||
packages: RoomPackages | undefined
|
||||
}
|
||||
|
||||
type RoomPackagePriceSchema = z.output<typeof packagePriceSchema>
|
||||
@@ -31,3 +19,12 @@ export type CalculatePricesPerNightProps = {
|
||||
petRoomRequestedPrice?: RoomPackagePriceSchema
|
||||
nights: number
|
||||
}
|
||||
|
||||
export interface RoomSizeProps {
|
||||
roomSize:
|
||||
| {
|
||||
max: number
|
||||
min: number
|
||||
}
|
||||
| undefined
|
||||
}
|
||||
|
||||
@@ -17,12 +17,6 @@ export interface DefaultFilterOptions {
|
||||
export type FilterValues = {
|
||||
[K in RoomPackageCodeEnum]?: boolean
|
||||
}
|
||||
export interface RoomFilterProps {
|
||||
numberOfRooms: number
|
||||
filterOptions: DefaultFilterOptions[]
|
||||
initialFilterValues: FilterValues
|
||||
roomListIndex: number
|
||||
}
|
||||
|
||||
export type RoomPackage = z.output<typeof packageSchema>
|
||||
export type RoomPackageCodes = RoomPackage["code"]
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
import type { Room } from "@/types/hotel"
|
||||
import type { RoomsAvailability } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type {
|
||||
DefaultFilterOptions,
|
||||
RoomPackageCodes,
|
||||
RoomPackages,
|
||||
} from "./roomFilter"
|
||||
|
||||
export interface RoomTypeListProps {
|
||||
availablePackages: RoomPackages | undefined
|
||||
hotelType: string | undefined
|
||||
roomCategories: Room[]
|
||||
roomListIndex: number
|
||||
roomsAvailability: RoomsAvailability
|
||||
selectedPackages: RoomPackageCodes[]
|
||||
}
|
||||
import type { RoomPackageCodes, RoomPackages } from "./roomFilter"
|
||||
|
||||
export interface SelectRateProps {
|
||||
availablePackages: RoomPackages
|
||||
@@ -23,12 +10,3 @@ export interface SelectRateProps {
|
||||
roomCategories: Room[]
|
||||
vat: number
|
||||
}
|
||||
|
||||
export interface RoomSelectionPanelProps {
|
||||
availablePackages: RoomPackages
|
||||
defaultPackages: DefaultFilterOptions[]
|
||||
hotelType: string | undefined
|
||||
roomCategories: Room[]
|
||||
roomListIndex: number
|
||||
selectedPackages: RoomPackageCodes[]
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import type { CreditCard, SafeUser } from "@/types/user"
|
||||
import type { PaymentMethodEnum } from "@/constants/booking"
|
||||
import type { Child } from "./selectRate"
|
||||
|
||||
export interface SectionProps {
|
||||
nextPath: string
|
||||
}
|
||||
|
||||
export interface BedSelectionProps extends SectionProps {
|
||||
alternatives: {
|
||||
value: string
|
||||
name: string
|
||||
payment: string
|
||||
pricePerNight: number
|
||||
membersPricePerNight: number
|
||||
currency: string
|
||||
}[]
|
||||
}
|
||||
|
||||
export interface BreakfastSelectionProps extends SectionProps {
|
||||
alternatives: {
|
||||
value: string
|
||||
name: string
|
||||
payment: string
|
||||
pricePerNight: number
|
||||
currency: string
|
||||
}[]
|
||||
}
|
||||
|
||||
export interface DetailsProps extends SectionProps {}
|
||||
|
||||
export interface PaymentProps {
|
||||
user: SafeUser
|
||||
otherPaymentOptions: PaymentMethodEnum[]
|
||||
mustBeGuaranteed: boolean
|
||||
supportedCards: PaymentMethodEnum[]
|
||||
}
|
||||
|
||||
export interface PaymentClientProps
|
||||
extends Omit<PaymentProps, "supportedCards"> {
|
||||
savedCreditCards: CreditCard[] | null
|
||||
}
|
||||
|
||||
export interface RoomParam {
|
||||
adults: number
|
||||
children?: Child[]
|
||||
}
|
||||
|
||||
export interface SectionPageProps {
|
||||
breakfast?: string
|
||||
bed?: string
|
||||
fromDate: string
|
||||
toDate: string
|
||||
room: RoomParam[]
|
||||
}
|
||||
@@ -12,31 +12,35 @@ export interface Child {
|
||||
|
||||
export interface Room {
|
||||
adults: number
|
||||
roomTypeCode: string
|
||||
rateCode: string
|
||||
counterRateCode: string
|
||||
childrenInRoom?: Child[]
|
||||
counterRateCode: string
|
||||
packages?: RoomPackageCodeEnum[]
|
||||
rateCode: string
|
||||
roomTypeCode: string
|
||||
}
|
||||
|
||||
export interface SelectRateSearchParams {
|
||||
city?: string
|
||||
hotelId: string
|
||||
fromDate: string
|
||||
toDate: string
|
||||
rooms: Room[]
|
||||
bookingCode?: string
|
||||
city?: string
|
||||
fromDate: string
|
||||
hotelId: string
|
||||
rooms: Room[]
|
||||
toDate: string
|
||||
}
|
||||
|
||||
export interface Rate {
|
||||
roomType: RoomConfiguration["roomType"]
|
||||
roomTypeCode: RoomConfiguration["roomTypeCode"]
|
||||
features: RoomConfiguration["features"]
|
||||
member?: Product["productType"]["member"]
|
||||
package?: RoomPackageCodeEnum | undefined
|
||||
priceName?: string
|
||||
priceTerm?: string
|
||||
public: Product["productType"]["public"]
|
||||
member?: Product["productType"]["member"]
|
||||
features: RoomConfiguration["features"]
|
||||
roomRates?: Array<{ roomIndex: number; rate: Rate }>
|
||||
roomRates?: {
|
||||
rate: Rate
|
||||
roomIndex: number
|
||||
}[]
|
||||
roomType: RoomConfiguration["roomType"]
|
||||
roomTypeCode: RoomConfiguration["roomTypeCode"]
|
||||
}
|
||||
|
||||
export type RateCode = {
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export type SelectionCardProps = {
|
||||
title: string
|
||||
subtext: string
|
||||
price: number
|
||||
membersPrice?: number
|
||||
currency: string
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export interface SummaryUIProps {
|
||||
isMember: boolean
|
||||
totalPrice: Price
|
||||
toggleSummaryOpen: () => void
|
||||
togglePriceDetailsModalOpen: () => void
|
||||
vat: number
|
||||
}
|
||||
|
||||
|
||||
3
types/contexts/rates.ts
Normal file
3
types/contexts/rates.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { createRatesStore } from "@/stores/select-rate"
|
||||
|
||||
export type RatesStore = ReturnType<typeof createRatesStore>
|
||||
12
types/contexts/room.ts
Normal file
12
types/contexts/room.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import type { SelectedRate, SelectedRoom } from "@/types/stores/rates"
|
||||
|
||||
export interface RoomContextValue extends SelectedRoom {
|
||||
actions: {
|
||||
modifyRate: () => void
|
||||
selectFilter: (code: RoomPackageCodeEnum | undefined) => void
|
||||
selectRate: (rate: SelectedRate) => void
|
||||
}
|
||||
isActiveRoom: boolean
|
||||
roomNr: number
|
||||
}
|
||||
14
types/providers/rates.ts
Normal file
14
types/providers/rates.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { Room } from "@/types/hotel"
|
||||
import type { Packages } from "@/types/requests/packages"
|
||||
import type { RoomsAvailability } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { SelectRateSearchParams } from "../components/hotelReservation/selectRate/selectRate"
|
||||
|
||||
export interface RatesProviderProps extends React.PropsWithChildren {
|
||||
booking: SelectRateSearchParams
|
||||
hotelType: string | undefined
|
||||
isUserLoggedIn: boolean
|
||||
packages: Packages | null
|
||||
roomCategories: Room[]
|
||||
roomsAvailability: RoomsAvailability | null
|
||||
vat: number
|
||||
}
|
||||
6
types/providers/room.ts
Normal file
6
types/providers/room.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { SelectedRoom } from "@/types/stores/rates"
|
||||
|
||||
export interface RoomProviderProps extends React.PropsWithChildren {
|
||||
idx: number
|
||||
room: SelectedRoom
|
||||
}
|
||||
76
types/stores/rates.ts
Normal file
76
types/stores/rates.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import type { ReadonlyURLSearchParams } from "next/navigation"
|
||||
|
||||
import type {
|
||||
DefaultFilterOptions,
|
||||
RoomPackageCodeEnum,
|
||||
} from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import type {
|
||||
Rate,
|
||||
Room as RoomBooking,
|
||||
SelectRateSearchParams,
|
||||
} from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import type { Room } from "@/types/hotel"
|
||||
import type { Packages } from "@/types/requests/packages"
|
||||
import type {
|
||||
Product,
|
||||
RoomConfiguration,
|
||||
RoomsAvailability,
|
||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
|
||||
interface Actions {
|
||||
modifyRate: (idx: number) => () => void
|
||||
selectFilter: (idx: number) => (code: RoomPackageCodeEnum | undefined) => void
|
||||
selectRate: (idx: number) => (rate: SelectedRate) => void
|
||||
}
|
||||
|
||||
export interface SelectedRate {
|
||||
features: RoomConfiguration["features"]
|
||||
product: Product
|
||||
roomType: RoomConfiguration["roomType"]
|
||||
roomTypeCode: RoomConfiguration["roomTypeCode"]
|
||||
}
|
||||
|
||||
export interface SelectedRoom {
|
||||
bookingRoom: RoomBooking
|
||||
rooms: RoomConfiguration[]
|
||||
selectedPackage: RoomPackageCodeEnum | undefined
|
||||
selectedRate: SelectedRate | null
|
||||
}
|
||||
|
||||
export interface RatesState {
|
||||
actions: Actions
|
||||
activeRoom: number
|
||||
allRooms: RoomConfiguration[]
|
||||
booking: SelectRateSearchParams
|
||||
filterOptions: DefaultFilterOptions[]
|
||||
hotelType: string | undefined
|
||||
packages: NonNullable<Packages>
|
||||
pathname: string
|
||||
petRoomPackage: NonNullable<Packages>[number] | undefined
|
||||
rateSummary: Rate[]
|
||||
rooms: SelectedRoom[]
|
||||
roomCategories: Room[]
|
||||
roomsAvailability: RoomsAvailability | null
|
||||
searchParams: ReadonlyURLSearchParams
|
||||
vat: number
|
||||
}
|
||||
|
||||
export interface InitialState
|
||||
extends Pick<
|
||||
RatesState,
|
||||
| "booking"
|
||||
| "hotelType"
|
||||
| "packages"
|
||||
| "pathname"
|
||||
| "roomCategories"
|
||||
| "roomsAvailability"
|
||||
| "searchParams"
|
||||
| "vat"
|
||||
> {
|
||||
isUserLoggedIn: boolean
|
||||
labels: {
|
||||
accessibilityRoom: string
|
||||
allergyRoom: string
|
||||
petRoom: string
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user