Merged in fix/SW-933-incorrect-ratecode (pull request #947)
Fix/SW-933 incorrect ratecode when creating booking as a member * fix(SW-933): Added check if member to select correct rate code in create booking * fix(SW-933): set member price in summary when "join" is true * fix(SW-933): change "price" -> "amount" and fix bool expression * fix(SW-933): added check for membership number in summary Approved-by: Christel Westerberg
This commit is contained in:
@@ -64,31 +64,33 @@ export default async function SummaryPage({
|
|||||||
redirect(selectRate(params.lang))
|
redirect(selectRate(params.lang))
|
||||||
}
|
}
|
||||||
|
|
||||||
const prices =
|
const prices = {
|
||||||
user && availability.memberRate
|
public: {
|
||||||
? {
|
|
||||||
local: {
|
local: {
|
||||||
price: availability.memberRate.localPrice.pricePerStay,
|
amount: availability.publicRate.localPrice.pricePerStay,
|
||||||
currency: availability.memberRate.localPrice.currency,
|
|
||||||
},
|
|
||||||
euro: availability.memberRate.requestedPrice
|
|
||||||
? {
|
|
||||||
price: availability.memberRate.requestedPrice.pricePerStay,
|
|
||||||
currency: availability.memberRate.requestedPrice.currency,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
local: {
|
|
||||||
price: availability.publicRate.localPrice.pricePerStay,
|
|
||||||
currency: availability.publicRate.localPrice.currency,
|
currency: availability.publicRate.localPrice.currency,
|
||||||
},
|
},
|
||||||
euro: availability.publicRate?.requestedPrice
|
euro: availability.publicRate?.requestedPrice
|
||||||
? {
|
? {
|
||||||
price: availability.publicRate?.requestedPrice.pricePerStay,
|
amount: availability.publicRate?.requestedPrice.pricePerStay,
|
||||||
currency: availability.publicRate?.requestedPrice.currency,
|
currency: availability.publicRate?.requestedPrice.currency,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
},
|
||||||
|
member: availability.memberRate
|
||||||
|
? {
|
||||||
|
local: {
|
||||||
|
amount: availability.memberRate.localPrice.pricePerStay,
|
||||||
|
currency: availability.memberRate.localPrice.currency,
|
||||||
|
},
|
||||||
|
euro: availability.memberRate.requestedPrice
|
||||||
|
? {
|
||||||
|
amount: availability.memberRate.requestedPrice.pricePerStay,
|
||||||
|
currency: availability.memberRate.requestedPrice.currency,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -100,8 +102,7 @@ export default async function SummaryPage({
|
|||||||
showMemberPrice={!!(user && availability.memberRate)}
|
showMemberPrice={!!(user && availability.memberRate)}
|
||||||
room={{
|
room={{
|
||||||
roomType: availability.selectedRoom.roomType,
|
roomType: availability.selectedRoom.roomType,
|
||||||
localPrice: prices.local,
|
prices,
|
||||||
euroPrice: prices.euro,
|
|
||||||
adults,
|
adults,
|
||||||
children,
|
children,
|
||||||
rateDetails: availability.rateDetails,
|
rateDetails: availability.rateDetails,
|
||||||
@@ -119,8 +120,7 @@ export default async function SummaryPage({
|
|||||||
showMemberPrice={!!(user && availability.memberRate)}
|
showMemberPrice={!!(user && availability.memberRate)}
|
||||||
room={{
|
room={{
|
||||||
roomType: availability.selectedRoom.roomType,
|
roomType: availability.selectedRoom.roomType,
|
||||||
localPrice: prices.local,
|
prices,
|
||||||
euroPrice: prices.euro,
|
|
||||||
adults,
|
adults,
|
||||||
children,
|
children,
|
||||||
rateDetails: availability.rateDetails,
|
rateDetails: availability.rateDetails,
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ export default async function StepPage({
|
|||||||
label={mustBeGuaranteed ? guaranteeWithCard : selectPaymentMethod}
|
label={mustBeGuaranteed ? guaranteeWithCard : selectPaymentMethod}
|
||||||
>
|
>
|
||||||
<Payment
|
<Payment
|
||||||
|
user={user}
|
||||||
roomPrice={roomPrice}
|
roomPrice={roomPrice}
|
||||||
otherPaymentOptions={
|
otherPaymentOptions={
|
||||||
hotelData.data.attributes.merchantInformationData
|
hotelData.data.attributes.merchantInformationData
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ function isPaymentMethodEnum(value: string): value is PaymentMethodEnum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Payment({
|
export default function Payment({
|
||||||
|
user,
|
||||||
roomPrice,
|
roomPrice,
|
||||||
otherPaymentOptions,
|
otherPaymentOptions,
|
||||||
savedCreditCards,
|
savedCreditCards,
|
||||||
@@ -185,7 +186,8 @@ export default function Payment({
|
|||||||
age: child.age,
|
age: child.age,
|
||||||
bedType: bedTypeMap[parseInt(child.bed.toString())],
|
bedType: bedTypeMap[parseInt(child.bed.toString())],
|
||||||
})),
|
})),
|
||||||
rateCode: room.rateCode,
|
rateCode:
|
||||||
|
user || join || membershipNo ? room.counterRateCode : room.rateCode,
|
||||||
roomTypeCode: bedType!.roomTypeCode, // A selection has been made in order to get to this step.
|
roomTypeCode: bedType!.roomTypeCode, // A selection has been made in order to get to this step.
|
||||||
guest: {
|
guest: {
|
||||||
title: "",
|
title: "",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function SummaryBottomSheet({ children }: PropsWithChildren) {
|
|||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
{ id: "{amount} {currency}" },
|
{ id: "{amount} {currency}" },
|
||||||
{
|
{
|
||||||
amount: intl.formatNumber(totalPrice.local.price),
|
amount: intl.formatNumber(totalPrice.local.amount),
|
||||||
currency: totalPrice.local.currency,
|
currency: totalPrice.local.currency,
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useRef, useState } from "react"
|
||||||
import { ChevronDown } from "react-feather"
|
import { ChevronDown } from "react-feather"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
@@ -33,6 +33,8 @@ function storeSelector(state: DetailsState) {
|
|||||||
toggleSummaryOpen: state.actions.toggleSummaryOpen,
|
toggleSummaryOpen: state.actions.toggleSummaryOpen,
|
||||||
setTotalPrice: state.actions.setTotalPrice,
|
setTotalPrice: state.actions.setTotalPrice,
|
||||||
totalPrice: state.totalPrice,
|
totalPrice: state.totalPrice,
|
||||||
|
join: state.data.join,
|
||||||
|
membershipNo: state.data.membershipNo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +53,8 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
toDate,
|
toDate,
|
||||||
toggleSummaryOpen,
|
toggleSummaryOpen,
|
||||||
totalPrice,
|
totalPrice,
|
||||||
|
join,
|
||||||
|
membershipNo,
|
||||||
} = useDetailsStore(storeSelector)
|
} = useDetailsStore(storeSelector)
|
||||||
|
|
||||||
const diff = dt(toDate).diff(fromDate, "days")
|
const diff = dt(toDate).diff(fromDate, "days")
|
||||||
@@ -60,10 +64,8 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
{ totalNights: diff }
|
{ totalNights: diff }
|
||||||
)
|
)
|
||||||
|
|
||||||
let color: "uiTextHighContrast" | "red" = "uiTextHighContrast"
|
const color = useRef<"uiTextHighContrast" | "red">("uiTextHighContrast")
|
||||||
if (showMemberPrice) {
|
const [price, setPrice] = useState(room.prices.public)
|
||||||
color = "red"
|
|
||||||
}
|
|
||||||
|
|
||||||
const additionalPackageCost = room.packages?.reduce(
|
const additionalPackageCost = room.packages?.reduce(
|
||||||
(acc, curr) => {
|
(acc, curr) => {
|
||||||
@@ -74,11 +76,23 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
{ local: 0, euro: 0 }
|
{ local: 0, euro: 0 }
|
||||||
) || { local: 0, euro: 0 }
|
) || { local: 0, euro: 0 }
|
||||||
|
|
||||||
const roomsPriceLocal = room.localPrice.price + additionalPackageCost.local
|
const roomsPriceLocal = price.local.amount + additionalPackageCost.local
|
||||||
const roomsPriceEuro = room.euroPrice
|
const roomsPriceEuro = price.euro
|
||||||
? room.euroPrice.price + additionalPackageCost.euro
|
? price.euro.amount + additionalPackageCost.euro
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showMemberPrice || join || membershipNo) {
|
||||||
|
color.current = "red"
|
||||||
|
if (room.prices.member) {
|
||||||
|
setPrice(room.prices.member)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
color.current = "uiTextHighContrast"
|
||||||
|
setPrice(room.prices.public)
|
||||||
|
}
|
||||||
|
}, [showMemberPrice, join, membershipNo, room.prices])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setChosenBed(bedType)
|
setChosenBed(bedType)
|
||||||
|
|
||||||
@@ -87,30 +101,30 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
if (breakfast === false) {
|
if (breakfast === false) {
|
||||||
setTotalPrice({
|
setTotalPrice({
|
||||||
local: {
|
local: {
|
||||||
price: roomsPriceLocal,
|
amount: roomsPriceLocal,
|
||||||
currency: room.localPrice.currency,
|
currency: price.local.currency,
|
||||||
},
|
},
|
||||||
euro:
|
euro:
|
||||||
room.euroPrice && roomsPriceEuro
|
price.euro && roomsPriceEuro
|
||||||
? {
|
? {
|
||||||
price: roomsPriceEuro,
|
amount: roomsPriceEuro,
|
||||||
currency: room.euroPrice.currency,
|
currency: price.euro.currency,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
setTotalPrice({
|
setTotalPrice({
|
||||||
local: {
|
local: {
|
||||||
price: roomsPriceLocal + parseInt(breakfast.localPrice.totalPrice),
|
amount: roomsPriceLocal + parseInt(breakfast.localPrice.totalPrice),
|
||||||
currency: room.localPrice.currency,
|
currency: price.local.currency,
|
||||||
},
|
},
|
||||||
euro:
|
euro:
|
||||||
room.euroPrice && roomsPriceEuro
|
price.euro && roomsPriceEuro
|
||||||
? {
|
? {
|
||||||
price:
|
amount:
|
||||||
roomsPriceEuro +
|
roomsPriceEuro +
|
||||||
parseInt(breakfast.requestedPrice.totalPrice),
|
parseInt(breakfast.requestedPrice.totalPrice),
|
||||||
currency: room.euroPrice.currency,
|
currency: price.euro.currency,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
})
|
})
|
||||||
@@ -120,8 +134,8 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
bedType,
|
bedType,
|
||||||
breakfast,
|
breakfast,
|
||||||
roomsPriceLocal,
|
roomsPriceLocal,
|
||||||
room.localPrice.currency,
|
price.local.currency,
|
||||||
room.euroPrice,
|
price.euro,
|
||||||
roomsPriceEuro,
|
roomsPriceEuro,
|
||||||
setTotalPrice,
|
setTotalPrice,
|
||||||
])
|
])
|
||||||
@@ -151,12 +165,12 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
<div>
|
<div>
|
||||||
<div className={styles.entry}>
|
<div className={styles.entry}>
|
||||||
<Body color="uiTextHighContrast">{room.roomType}</Body>
|
<Body color="uiTextHighContrast">{room.roomType}</Body>
|
||||||
<Caption color={color}>
|
<Caption color={color.current}>
|
||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
{ id: "{amount} {currency}" },
|
{ id: "{amount} {currency}" },
|
||||||
{
|
{
|
||||||
amount: intl.formatNumber(room.localPrice.price),
|
amount: intl.formatNumber(price.local.amount),
|
||||||
currency: room.localPrice.currency,
|
currency: price.local.currency,
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
</Caption>
|
</Caption>
|
||||||
@@ -229,7 +243,7 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
<Caption color="uiTextHighContrast">
|
<Caption color="uiTextHighContrast">
|
||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
{ id: "{amount} {currency}" },
|
{ id: "{amount} {currency}" },
|
||||||
{ amount: "0", currency: room.localPrice.currency }
|
{ amount: "0", currency: price.local.currency }
|
||||||
)}
|
)}
|
||||||
</Caption>
|
</Caption>
|
||||||
</div>
|
</div>
|
||||||
@@ -243,7 +257,7 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
<Caption color="uiTextMediumContrast">
|
<Caption color="uiTextMediumContrast">
|
||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
{ id: "{amount} {currency}" },
|
{ id: "{amount} {currency}" },
|
||||||
{ amount: "0", currency: room.localPrice.currency }
|
{ amount: "0", currency: price.local.currency }
|
||||||
)}
|
)}
|
||||||
</Caption>
|
</Caption>
|
||||||
</div>
|
</div>
|
||||||
@@ -279,22 +293,24 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
|
|||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
{totalPrice.local.amount > 0 && (
|
||||||
<Body textTransform="bold">
|
<Body textTransform="bold">
|
||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
{ id: "{amount} {currency}" },
|
{ id: "{amount} {currency}" },
|
||||||
{
|
{
|
||||||
amount: intl.formatNumber(totalPrice.local.price),
|
amount: intl.formatNumber(totalPrice.local.amount),
|
||||||
currency: totalPrice.local.currency,
|
currency: totalPrice.local.currency,
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
</Body>
|
</Body>
|
||||||
{totalPrice.euro && (
|
)}
|
||||||
|
{totalPrice.euro && totalPrice.euro.amount > 0 && (
|
||||||
<Caption color="uiTextMediumContrast">
|
<Caption color="uiTextMediumContrast">
|
||||||
{intl.formatMessage({ id: "Approx." })}{" "}
|
{intl.formatMessage({ id: "Approx." })}{" "}
|
||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
{ id: "{amount} {currency}" },
|
{ id: "{amount} {currency}" },
|
||||||
{
|
{
|
||||||
amount: intl.formatNumber(totalPrice.euro.price),
|
amount: intl.formatNumber(totalPrice.euro.amount),
|
||||||
currency: totalPrice.euro.currency,
|
currency: totalPrice.euro.currency,
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ export function getQueryParamsForEnterDetails(
|
|||||||
roomTypeCode: room.roomtype,
|
roomTypeCode: room.roomtype,
|
||||||
rateCode: room.ratecode,
|
rateCode: room.ratecode,
|
||||||
packages: room.packages?.split(",") as RoomPackageCodeEnum[],
|
packages: room.packages?.split(",") as RoomPackageCodeEnum[],
|
||||||
|
counterRateCode: room.counterratecode,
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ export function createDetailsStore(
|
|||||||
},
|
},
|
||||||
|
|
||||||
totalPrice: {
|
totalPrice: {
|
||||||
euro: { currency: "", price: 0 },
|
euro: { currency: "", amount: 0 },
|
||||||
local: { currency: "", price: 0 },
|
local: { currency: "", amount: 0 },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ interface Room {
|
|||||||
adults: number
|
adults: number
|
||||||
roomTypeCode: string
|
roomTypeCode: string
|
||||||
rateCode: string
|
rateCode: string
|
||||||
|
counterRateCode: string
|
||||||
children?: Child[]
|
children?: Child[]
|
||||||
packages?: RoomPackageCodeEnum[]
|
packages?: RoomPackageCodeEnum[]
|
||||||
}
|
}
|
||||||
@@ -18,14 +19,24 @@ export interface BookingData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Price = {
|
type Price = {
|
||||||
price: number
|
amount: number
|
||||||
currency: string
|
currency: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RoomsData = {
|
export type RoomsData = {
|
||||||
roomType: string
|
roomType: string
|
||||||
localPrice: Price
|
prices: {
|
||||||
euroPrice: Price | undefined
|
public: {
|
||||||
|
local: Price
|
||||||
|
euro: Price | undefined
|
||||||
|
}
|
||||||
|
member:
|
||||||
|
| {
|
||||||
|
local: Price
|
||||||
|
euro: Price | undefined
|
||||||
|
}
|
||||||
|
| undefined
|
||||||
|
}
|
||||||
adults: number
|
adults: number
|
||||||
children?: Child[]
|
children?: Child[]
|
||||||
rateDetails?: string[]
|
rateDetails?: string[]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CreditCard } from "@/types/user"
|
import { CreditCard, SafeUser } from "@/types/user"
|
||||||
|
|
||||||
export interface SectionProps {
|
export interface SectionProps {
|
||||||
nextPath: string
|
nextPath: string
|
||||||
@@ -28,6 +28,7 @@ export interface BreakfastSelectionProps extends SectionProps {
|
|||||||
export interface DetailsProps extends SectionProps {}
|
export interface DetailsProps extends SectionProps {}
|
||||||
|
|
||||||
export interface PaymentProps {
|
export interface PaymentProps {
|
||||||
|
user: SafeUser
|
||||||
roomPrice: { publicPrice: number; memberPrice: number | undefined }
|
roomPrice: { publicPrice: number; memberPrice: number | undefined }
|
||||||
otherPaymentOptions: string[]
|
otherPaymentOptions: string[]
|
||||||
savedCreditCards: CreditCard[] | null
|
savedCreditCards: CreditCard[] | null
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ interface Room {
|
|||||||
adults: number
|
adults: number
|
||||||
roomtype: string
|
roomtype: string
|
||||||
ratecode: string
|
ratecode: string
|
||||||
counterratecode?: string
|
counterratecode: string
|
||||||
child?: Child[]
|
child?: Child[]
|
||||||
packages?: string
|
packages?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export interface DetailsState {
|
|||||||
actions: {
|
actions: {
|
||||||
setIsSubmittingDisabled: (isSubmittingDisabled: boolean) => void
|
setIsSubmittingDisabled: (isSubmittingDisabled: boolean) => void
|
||||||
setTotalPrice: (totalPrice: TotalPrice) => void
|
setTotalPrice: (totalPrice: TotalPrice) => void
|
||||||
toggleSummaryOpen: () => void,
|
toggleSummaryOpen: () => void
|
||||||
updateBedType: (data: BedTypeSchema) => void
|
updateBedType: (data: BedTypeSchema) => void
|
||||||
updateBreakfast: (data: BreakfastPackage | false) => void
|
updateBreakfast: (data: BreakfastPackage | false) => void
|
||||||
updateDetails: (data: DetailsSchema) => void
|
updateDetails: (data: DetailsSchema) => void
|
||||||
@@ -31,7 +31,7 @@ export interface InitialState extends Partial<DetailsState> {
|
|||||||
|
|
||||||
interface Price {
|
interface Price {
|
||||||
currency: string
|
currency: string
|
||||||
price: number
|
amount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TotalPrice {
|
export interface TotalPrice {
|
||||||
|
|||||||
Reference in New Issue
Block a user