feat: SW-1588 Updated rate selection
This commit is contained in:
@@ -27,6 +27,7 @@ export default function FlexibilityOption({
|
|||||||
roomType,
|
roomType,
|
||||||
roomTypeCode,
|
roomTypeCode,
|
||||||
title,
|
title,
|
||||||
|
rateTitle,
|
||||||
}: FlexibilityOptionProps) {
|
}: FlexibilityOptionProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const { data: session } = useSession()
|
const { data: session } = useSession()
|
||||||
@@ -82,6 +83,11 @@ export default function FlexibilityOption({
|
|||||||
value={rate.rateCode}
|
value={rate.rateCode}
|
||||||
/>
|
/>
|
||||||
<div className={styles.card}>
|
<div className={styles.card}>
|
||||||
|
{rateTitle ? (
|
||||||
|
<div className={styles.header}>
|
||||||
|
<Caption>{rateTitle}</Caption>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<Modal
|
<Modal
|
||||||
trigger={
|
trigger={
|
||||||
@@ -93,8 +99,8 @@ export default function FlexibilityOption({
|
|||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
title={title}
|
title={rateTitle ? rateTitle : title}
|
||||||
subtitle={paymentTerm}
|
subtitle={rateTitle ? `${title} (${paymentTerm})` : paymentTerm}
|
||||||
>
|
>
|
||||||
<div className={styles.terms}>
|
<div className={styles.terms}>
|
||||||
{priceInformation?.map((info) => (
|
{priceInformation?.map((info) => (
|
||||||
|
|||||||
@@ -147,34 +147,34 @@ export default function RoomCard({ roomConfiguration }: RoomCardProps) {
|
|||||||
const payNow = intl.formatMessage({ id: "Pay now" })
|
const payNow = intl.formatMessage({ id: "Pay now" })
|
||||||
|
|
||||||
function getRate(rateCode: string, rateDefinition?: RateDefinition) {
|
function getRate(rateCode: string, rateDefinition?: RateDefinition) {
|
||||||
|
const rateObj = {
|
||||||
|
terms: rateDefinition?.generalTerms,
|
||||||
|
rateTitle:
|
||||||
|
rateDefinition?.rateType !== RateTypeEnum.Regular
|
||||||
|
? rateDefinition?.title
|
||||||
|
: undefined,
|
||||||
|
}
|
||||||
switch (rateCode) {
|
switch (rateCode) {
|
||||||
case "change":
|
case "change":
|
||||||
return {
|
return {
|
||||||
isFlex: false,
|
isFlex: false,
|
||||||
notAvailable: false,
|
notAvailable: false,
|
||||||
title: freeBooking,
|
title: freeBooking,
|
||||||
terms: rateDefinition?.generalTerms,
|
...rateObj,
|
||||||
}
|
}
|
||||||
case "flex":
|
case "flex":
|
||||||
return {
|
return {
|
||||||
isFlex: true,
|
isFlex: true,
|
||||||
notAvailable: false,
|
notAvailable: false,
|
||||||
title: freeCancelation,
|
title: freeCancelation,
|
||||||
terms: rateDefinition?.generalTerms,
|
...rateObj,
|
||||||
}
|
}
|
||||||
case "save":
|
case "save":
|
||||||
return {
|
return {
|
||||||
isFlex: false,
|
isFlex: false,
|
||||||
notAvailable: false,
|
notAvailable: false,
|
||||||
title: nonRefundable,
|
title: nonRefundable,
|
||||||
terms: rateDefinition?.generalTerms,
|
...rateObj,
|
||||||
}
|
|
||||||
case "special":
|
|
||||||
return {
|
|
||||||
isFlex: rateDefinition?.cancellationRule === "CancellableBefore6PM",
|
|
||||||
notAvailable: false,
|
|
||||||
title: rateDefinition?.title ?? "",
|
|
||||||
terms: rateDefinition?.generalTerms,
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -207,6 +207,7 @@ export default function RoomCard({ roomConfiguration }: RoomCardProps) {
|
|||||||
notAvailable: true,
|
notAvailable: true,
|
||||||
title: "",
|
title: "",
|
||||||
terms: undefined,
|
terms: undefined,
|
||||||
|
rateTitle: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,23 +332,30 @@ export default function RoomCard({ roomConfiguration }: RoomCardProps) {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Caption color="uiTextHighContrast">{breakfastMessage}</Caption>
|
<span>
|
||||||
{bookingCode ? (
|
<Caption color="uiTextHighContrast">{breakfastMessage}</Caption>
|
||||||
<span className={!isSpecialRate ? styles.strikedText : ""}>
|
{bookingCode ? (
|
||||||
<PriceTagIcon />
|
<span className={!isSpecialRate ? styles.strikedText : ""}>
|
||||||
{bookingCode}
|
<PriceTagIcon />
|
||||||
</span>
|
{bookingCode}
|
||||||
) : null}
|
</span>
|
||||||
|
) : null}
|
||||||
|
</span>
|
||||||
{roomConfiguration.products.map((product) => {
|
{roomConfiguration.products.map((product) => {
|
||||||
const rate = getRateInfo(product)
|
const rate = getRateInfo(product)
|
||||||
const isSelectedRateCode =
|
const isSelectedRateCode =
|
||||||
selectedRate?.product.productType.public.rateCode ===
|
selectedRate?.product.productType.public.rateCode ===
|
||||||
product.productType.public.rateCode ||
|
product.productType.public.rateCode ||
|
||||||
selectedRate?.product.productType.member?.rateCode ===
|
(selectedRate?.product.productType.member?.rateCode ===
|
||||||
product.productType.member?.rateCode
|
product.productType.member?.rateCode &&
|
||||||
|
product.productType.member?.rateCode !== undefined)
|
||||||
return (
|
return (
|
||||||
<FlexibilityOption
|
<FlexibilityOption
|
||||||
key={product.productType.public.rateCode}
|
key={
|
||||||
|
product.productType.public.rateCode +
|
||||||
|
"_" +
|
||||||
|
product.productType.public.rate
|
||||||
|
}
|
||||||
features={roomConfiguration.features}
|
features={roomConfiguration.features}
|
||||||
isSelected={
|
isSelected={
|
||||||
isSelectedRateCode &&
|
isSelectedRateCode &&
|
||||||
@@ -361,6 +369,7 @@ export default function RoomCard({ roomConfiguration }: RoomCardProps) {
|
|||||||
roomTypeCode={roomConfiguration.roomTypeCode}
|
roomTypeCode={roomConfiguration.roomTypeCode}
|
||||||
title={rate.title}
|
title={rate.title}
|
||||||
priceInformation={rate.terms}
|
priceInformation={rate.terms}
|
||||||
|
rateTitle={rate.rateTitle}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { trpc } from "@/lib/trpc/client"
|
|||||||
|
|
||||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||||
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
|
||||||
import type { RoomsAvailability } from "@/types/trpc/routers/hotel/roomAvailability"
|
import type { RoomsAvailability } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||||
import type { Lang } from "@/constants/languages"
|
import type { Lang } from "@/constants/languages"
|
||||||
|
|
||||||
@@ -39,17 +38,14 @@ export function getRates(
|
|||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
change: rateDefinitions.filter(
|
change: rateDefinitions.filter(
|
||||||
(rate) => rate.cancellationRule === "Changeable" && rate.rateType === RateTypeEnum.Regular
|
(rate) => rate.cancellationRule === "Changeable"
|
||||||
),
|
),
|
||||||
flex: rateDefinitions.filter(
|
flex: rateDefinitions.filter(
|
||||||
(rate) => rate.cancellationRule === "CancellableBefore6PM" && rate.rateType === RateTypeEnum.Regular
|
(rate) => rate.cancellationRule === "CancellableBefore6PM"
|
||||||
),
|
),
|
||||||
save: rateDefinitions.filter(
|
save: rateDefinitions.filter(
|
||||||
(rate) => rate.cancellationRule === "NotCancellable" && rate.rateType === RateTypeEnum.Regular
|
(rate) => rate.cancellationRule === "NotCancellable"
|
||||||
),
|
),
|
||||||
special: rateDefinitions.filter(
|
|
||||||
(rate) => rate.rateType !== RateTypeEnum.Regular
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export type FlexibilityOptionProps = {
|
|||||||
roomType: RoomConfiguration["roomType"]
|
roomType: RoomConfiguration["roomType"]
|
||||||
roomTypeCode: RoomConfiguration["roomTypeCode"]
|
roomTypeCode: RoomConfiguration["roomTypeCode"]
|
||||||
title: string
|
title: string
|
||||||
|
rateTitle?: string // This is for special rates via booking codes
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PriceListProps {
|
export interface PriceListProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user