feat(SW-1717): rewrite select-rate to show all variants of rate-cards
This commit is contained in:
committed by
Michael Zetterberg
parent
adde77eaa9
commit
ebaea78fb3
@@ -4,7 +4,7 @@ export interface AncillaryCardProps {
|
||||
imageUrl: string
|
||||
imageOpacity?: number
|
||||
price: {
|
||||
totalPrice: number
|
||||
total: number
|
||||
currency: string
|
||||
text?: string
|
||||
included?: boolean
|
||||
|
||||
@@ -28,10 +28,4 @@ export type JoinScandicFriendsCardProps = {
|
||||
name?: string
|
||||
}
|
||||
|
||||
export type RoomRate = {
|
||||
memberRate?: NonNullable<Product["member"]>
|
||||
publicRate?: NonNullable<Product["public"]>
|
||||
voucherRate?: NonNullable<Product["voucher"]>
|
||||
chequeRate?: NonNullable<Product["bonusCheque"]>
|
||||
redemptionRate?: ProductTypePointsSchema
|
||||
}
|
||||
export type RoomRate = Product
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import type { RoomAvailability } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
|
||||
export interface ClientSummaryProps
|
||||
extends Pick<
|
||||
RoomAvailability,
|
||||
"cancellationText" | "memberRate" | "rateDetails"
|
||||
>,
|
||||
Pick<RoomAvailability["selectedRoom"], "roomType"> {
|
||||
adults: number
|
||||
isMember: boolean
|
||||
kids: Child[] | undefined
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import type {
|
||||
} from "@/server/routers/hotels/schemas/productTypePrice"
|
||||
import type { RoomPackage } from "./roomFilter"
|
||||
|
||||
type ProductPrice = z.output<typeof productTypePriceSchema>
|
||||
export type ProductPrice = z.output<typeof productTypePriceSchema>
|
||||
export type RoomPriceSchema = z.output<typeof priceSchema>
|
||||
|
||||
export type FlexibilityOptionProps = {
|
||||
@@ -32,8 +32,8 @@ export interface FlexibilityOptionVoucherProps
|
||||
export type FlexibilityOptionChequeProps = FlexibilityOptionVoucherProps
|
||||
|
||||
export interface PriceListProps {
|
||||
publicPrice?: ProductPrice | Record<string, never>
|
||||
memberPrice?: ProductPrice | Record<string, never>
|
||||
publicPrice: ProductPrice
|
||||
memberPrice: ProductPrice
|
||||
petRoomPackage?: RoomPackage
|
||||
rateName?: string // Obtained in case of booking code and redemption rates
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { Packages } from "@/types/requests/packages"
|
||||
import type {
|
||||
Product,
|
||||
RoomConfiguration,
|
||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
|
||||
export interface RatesProps {
|
||||
roomConfiguration: RoomConfiguration
|
||||
}
|
||||
|
||||
export interface SharedRateCardProps extends Pick<
|
||||
RoomConfiguration,
|
||||
"roomTypeCode"
|
||||
> {
|
||||
handleSelectRate: (product: Product) => void
|
||||
nights: number
|
||||
petRoomPackage: NonNullable<Packages>[number] | undefined
|
||||
}
|
||||
+16
-8
@@ -4,17 +4,25 @@ import type { RoomConfiguration } from "@/types/trpc/routers/hotel/roomAvailabil
|
||||
import type { packagePriceSchema } from "@/server/routers/hotels/schemas/packages"
|
||||
import type { RoomPriceSchema } from "./flexibilityOption"
|
||||
|
||||
export type RoomCardProps = {
|
||||
export type RoomListItemProps = {
|
||||
roomConfiguration: RoomConfiguration
|
||||
}
|
||||
|
||||
export type RoomListItemImageProps = Pick<
|
||||
RoomConfiguration,
|
||||
| "features"
|
||||
| "roomType"
|
||||
| "roomTypeCode"
|
||||
| "roomsLeft"
|
||||
>
|
||||
|
||||
type RoomPackagePriceSchema = z.output<typeof packagePriceSchema>
|
||||
|
||||
export type CalculatePricesPerNightProps = {
|
||||
publicLocalPrice: RoomPriceSchema
|
||||
memberLocalPrice: RoomPriceSchema
|
||||
publicRequestedPrice?: RoomPriceSchema
|
||||
memberRequestedPrice?: RoomPriceSchema
|
||||
publicRequestedPrice: RoomPriceSchema | null
|
||||
memberRequestedPrice: RoomPriceSchema | null
|
||||
petRoomLocalPrice?: RoomPackagePriceSchema
|
||||
petRoomRequestedPrice?: RoomPackagePriceSchema
|
||||
nights: number
|
||||
@@ -22,9 +30,9 @@ export type CalculatePricesPerNightProps = {
|
||||
|
||||
export interface RoomSizeProps {
|
||||
roomSize:
|
||||
| {
|
||||
max: number
|
||||
min: number
|
||||
}
|
||||
| undefined
|
||||
| {
|
||||
max: number
|
||||
min: number
|
||||
}
|
||||
| undefined
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import type {
|
||||
RoomConfiguration,
|
||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { ChildBedMapEnum } from "../../bookingWidget/enums"
|
||||
import type { ProductTypePointsSchema } from "../enterDetails/details"
|
||||
import type { RoomPackageCodeEnum } from "./roomFilter"
|
||||
|
||||
export interface Child {
|
||||
@@ -35,6 +34,7 @@ export type Rate = {
|
||||
package?: RoomPackageCodeEnum | undefined
|
||||
priceName?: string
|
||||
priceTerm?: string
|
||||
product: Product
|
||||
rate: "change" | "flex" | "save"
|
||||
roomRates?: {
|
||||
rate: Rate
|
||||
@@ -42,36 +42,7 @@ export type Rate = {
|
||||
}[]
|
||||
roomType: RoomConfiguration["roomType"]
|
||||
roomTypeCode: RoomConfiguration["roomTypeCode"]
|
||||
} & (
|
||||
| {
|
||||
bonusCheque?: never
|
||||
member?: NonNullable<Product["member"]>
|
||||
public?: NonNullable<Product["public"]>
|
||||
redemption?: never
|
||||
voucher?: never
|
||||
}
|
||||
| {
|
||||
bonusCheque?: never
|
||||
member?: never
|
||||
public?: never
|
||||
redemption?: never
|
||||
voucher?: NonNullable<Product["voucher"]>
|
||||
}
|
||||
| {
|
||||
bonusCheque?: NonNullable<Product["bonusCheque"]>
|
||||
member?: never
|
||||
public?: never
|
||||
redemption?: never
|
||||
voucher?: never
|
||||
}
|
||||
| {
|
||||
bonusCheque?: never
|
||||
member?: never
|
||||
public?: never
|
||||
redemption?: NonNullable<ProductTypePointsSchema>
|
||||
voucher?: never
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export type RateCode = {
|
||||
publicRateCode: string
|
||||
|
||||
@@ -1,24 +1,9 @@
|
||||
import type { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import type {
|
||||
RatesState,
|
||||
SelectedRate,
|
||||
SelectedRoom,
|
||||
} from "@/types/stores/rates"
|
||||
import type { RatesState, SelectedRoom } from "@/types/stores/rates"
|
||||
|
||||
export interface RoomContextValue extends SelectedRoom {
|
||||
actions: {
|
||||
closeSection: () => void
|
||||
modifyRate: () => void
|
||||
selectFilter: (code: RoomPackageCodeEnum | undefined) => void
|
||||
selectRate: (rate: SelectedRate) => void
|
||||
selectRateRedemption: (
|
||||
rate: SelectedRate,
|
||||
selectedRateCode?: string
|
||||
) => void
|
||||
selectRateCheque: (rate: SelectedRate) => void
|
||||
selectRateVoucher: (rate: SelectedRate) => void
|
||||
}
|
||||
export interface RoomContextValue extends Omit<SelectedRoom, "actions"> {
|
||||
actions: Omit<SelectedRoom["actions"], "appendRegularRates">
|
||||
isActiveRoom: boolean
|
||||
isFetchingAdditionalRate: boolean
|
||||
isMainRoom: boolean
|
||||
roomAvailability:
|
||||
| NonNullable<RatesState["roomsAvailability"]>[number]
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// API keeps calling CorporateCheque BonusCheque
|
||||
// (will be handled in transform later)
|
||||
export enum RateTypeEnum {
|
||||
Arb = "Arb",
|
||||
BonusCheque = "BonusCheque",
|
||||
Company = "Company",
|
||||
CorporateCheque = "BonusCheque",
|
||||
Promotion = "Promotion",
|
||||
PublicPromotion = "PublicPromotion",
|
||||
Redemption = "Redemption",
|
||||
|
||||
@@ -58,6 +58,13 @@ export interface Room extends InitialRoomData {
|
||||
}
|
||||
|
||||
export interface RoomState {
|
||||
actions: {
|
||||
setStep: (step: StepEnum) => void
|
||||
updateBedType: (data: BedTypeSchema) => void
|
||||
updateBreakfast: (data: BreakfastPackage | false) => void
|
||||
updateDetails: (data: DetailsSchema) => void
|
||||
updateMultiroomDetails: (data: MultiroomDetailsSchema) => void
|
||||
}
|
||||
currentStep: StepEnum | null
|
||||
isComplete: boolean
|
||||
room: Room
|
||||
@@ -76,16 +83,9 @@ export type InitialState = {
|
||||
|
||||
export interface DetailsState {
|
||||
actions: {
|
||||
setStep: (idx: number) => (step: StepEnum) => void
|
||||
setIsSubmittingDisabled: (isSubmittingDisabled: boolean) => void
|
||||
setTotalPrice: (totalPrice: Price) => void
|
||||
toggleSummaryOpen: () => 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
|
||||
|
||||
@@ -16,6 +16,7 @@ import type {
|
||||
RoomConfiguration,
|
||||
RoomsAvailability,
|
||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
import type { BookingCodeFilterEnum } from "../enums/bookingCodeFilter"
|
||||
|
||||
export interface AvailabilityError {
|
||||
details: string
|
||||
@@ -23,15 +24,12 @@ export interface AvailabilityError {
|
||||
}
|
||||
|
||||
interface Actions {
|
||||
closeSection: (idx: number) => () => void
|
||||
modifyRate: (idx: number) => () => void
|
||||
selectFilter: (idx: number) => (code: RoomPackageCodeEnum | undefined) => void
|
||||
selectRate: (idx: number) => (rate: SelectedRate) => void
|
||||
selectRateRedemption: (
|
||||
idx: number
|
||||
) => (rate: SelectedRate, selectedRateCode?: string) => void
|
||||
selectRateVoucher: (idx: number) => (rate: SelectedRate) => void
|
||||
selectRateCheque: (idx: number) => (rate: SelectedRate) => void
|
||||
appendRegularRates: (roomConfigurations: RoomConfiguration[]) => void
|
||||
closeSection: () => void
|
||||
modifyRate: () => void
|
||||
selectFilter: (filter: BookingCodeFilterEnum) => void
|
||||
selectPackage: (code: RoomPackageCodeEnum | undefined) => void
|
||||
selectRate: (rate: SelectedRate) => void
|
||||
}
|
||||
|
||||
export interface SelectedRate {
|
||||
@@ -42,14 +40,15 @@ export interface SelectedRate {
|
||||
}
|
||||
|
||||
export interface SelectedRoom {
|
||||
actions: Actions
|
||||
bookingRoom: RoomBooking
|
||||
rooms: RoomConfiguration[]
|
||||
selectedFilter: BookingCodeFilterEnum | undefined
|
||||
selectedPackage: RoomPackageCodeEnum | undefined
|
||||
selectedRate: SelectedRate | null
|
||||
}
|
||||
|
||||
export interface RatesState {
|
||||
actions: Actions
|
||||
activeRoom: number
|
||||
booking: SelectRateSearchParams
|
||||
filterOptions: DefaultFilterOptions[]
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { z } from "zod"
|
||||
import type { hotelsAvailabilitySchema } from "@/server/routers/hotels/output"
|
||||
import type { productTypeSchema } from "@/server/routers/hotels/schemas/availability/productType"
|
||||
import type {
|
||||
productTypeChequeSchema,
|
||||
productTypeCorporateChequeSchema,
|
||||
productTypePointsSchema,
|
||||
productTypePriceSchema,
|
||||
productTypeVoucherSchema,
|
||||
@@ -33,7 +33,9 @@ export type ProductType = z.output<typeof productTypeSchema>
|
||||
export type ProductTypePrices = z.output<typeof productTypePriceSchema>
|
||||
export type ProductTypePoints = z.output<typeof productTypePointsSchema>
|
||||
export type ProductTypeVoucher = z.output<typeof productTypeVoucherSchema>
|
||||
export type ProductTypeCheque = z.output<typeof productTypeChequeSchema>
|
||||
export type ProductTypeCheque = z.output<
|
||||
typeof productTypeCorporateChequeSchema
|
||||
>
|
||||
|
||||
export type HotelsAvailabilityItem =
|
||||
HotelsAvailability["data"][number]["attributes"]
|
||||
|
||||
@@ -3,14 +3,34 @@ import type { z } from "zod"
|
||||
import type { RouterOutput } from "@/lib/trpc/client"
|
||||
import type { roomsAvailabilitySchema } from "@/server/routers/hotels/output"
|
||||
import type { roomConfigurationSchema } from "@/server/routers/hotels/schemas/roomAvailability/configuration"
|
||||
import type { productSchema } from "@/server/routers/hotels/schemas/roomAvailability/product"
|
||||
import type {
|
||||
corporateChequeProduct,
|
||||
priceProduct,
|
||||
productSchema,
|
||||
redemptionProduct,
|
||||
redemptionsProduct,
|
||||
voucherProduct,
|
||||
} from "@/server/routers/hotels/schemas/roomAvailability/product"
|
||||
import type { rateDefinitionSchema } from "@/server/routers/hotels/schemas/roomAvailability/rateDefinition"
|
||||
|
||||
export type RoomAvailability = NonNullable<
|
||||
RouterOutput["hotel"]["availability"]["room"]
|
||||
>
|
||||
|
||||
export type Product = z.output<typeof productSchema>
|
||||
export type CorporateChequeProduct = z.output<typeof corporateChequeProduct>
|
||||
export type PriceProduct = z.output<typeof priceProduct>
|
||||
export type RedemptionProduct = z.output<typeof redemptionProduct>
|
||||
export type RedemptionsProduct = z.output<typeof redemptionsProduct>
|
||||
export type VoucherProduct = z.output<typeof voucherProduct>
|
||||
|
||||
export type CodeProduct = CorporateChequeProduct | PriceProduct | VoucherProduct
|
||||
export type Products = z.output<typeof productSchema>
|
||||
export type Product =
|
||||
| CorporateChequeProduct
|
||||
| PriceProduct
|
||||
| RedemptionProduct
|
||||
| VoucherProduct
|
||||
|
||||
export type RateDefinition = z.output<typeof rateDefinitionSchema>
|
||||
export type RoomConfiguration = z.output<typeof roomConfigurationSchema>
|
||||
export type RoomsAvailability = z.output<typeof roomsAvailabilitySchema>
|
||||
|
||||
Reference in New Issue
Block a user