diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@summary/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@summary/page.tsx index 0444913f1..0fb655de6 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@summary/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@summary/page.tsx @@ -64,32 +64,34 @@ export default async function SummaryPage({ redirect(selectRate(params.lang)) } - const prices = - user && availability.memberRate + const prices = { + public: { + local: { + amount: availability.publicRate.localPrice.pricePerStay, + currency: availability.publicRate.localPrice.currency, + }, + euro: availability.publicRate?.requestedPrice + ? { + amount: availability.publicRate?.requestedPrice.pricePerStay, + currency: availability.publicRate?.requestedPrice.currency, + } + : undefined, + }, + member: availability.memberRate ? { local: { - price: availability.memberRate.localPrice.pricePerStay, + amount: availability.memberRate.localPrice.pricePerStay, currency: availability.memberRate.localPrice.currency, }, euro: availability.memberRate.requestedPrice ? { - price: availability.memberRate.requestedPrice.pricePerStay, + amount: availability.memberRate.requestedPrice.pricePerStay, currency: availability.memberRate.requestedPrice.currency, } : undefined, } - : { - local: { - price: availability.publicRate.localPrice.pricePerStay, - currency: availability.publicRate.localPrice.currency, - }, - euro: availability.publicRate?.requestedPrice - ? { - price: availability.publicRate?.requestedPrice.pricePerStay, - currency: availability.publicRate?.requestedPrice.currency, - } - : undefined, - } + : undefined, + } return ( <> @@ -100,8 +102,7 @@ export default async function SummaryPage({ showMemberPrice={!!(user && availability.memberRate)} room={{ roomType: availability.selectedRoom.roomType, - localPrice: prices.local, - euroPrice: prices.euro, + prices, adults, children, rateDetails: availability.rateDetails, @@ -119,8 +120,7 @@ export default async function SummaryPage({ showMemberPrice={!!(user && availability.memberRate)} room={{ roomType: availability.selectedRoom.roomType, - localPrice: prices.local, - euroPrice: prices.euro, + prices, adults, children, rateDetails: availability.rateDetails, diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx index d175fc25f..4fbaae7ff 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx @@ -171,6 +171,7 @@ export default async function StepPage({ label={mustBeGuaranteed ? guaranteeWithCard : selectPaymentMethod} > ("uiTextHighContrast") + const [price, setPrice] = useState(room.prices.public) const additionalPackageCost = room.packages?.reduce( (acc, curr) => { @@ -74,11 +76,23 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) { { local: 0, euro: 0 } ) || { local: 0, euro: 0 } - const roomsPriceLocal = room.localPrice.price + additionalPackageCost.local - const roomsPriceEuro = room.euroPrice - ? room.euroPrice.price + additionalPackageCost.euro + const roomsPriceLocal = price.local.amount + additionalPackageCost.local + const roomsPriceEuro = price.euro + ? price.euro.amount + additionalPackageCost.euro : 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(() => { setChosenBed(bedType) @@ -87,30 +101,30 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) { if (breakfast === false) { setTotalPrice({ local: { - price: roomsPriceLocal, - currency: room.localPrice.currency, + amount: roomsPriceLocal, + currency: price.local.currency, }, euro: - room.euroPrice && roomsPriceEuro + price.euro && roomsPriceEuro ? { - price: roomsPriceEuro, - currency: room.euroPrice.currency, + amount: roomsPriceEuro, + currency: price.euro.currency, } : undefined, }) } else { setTotalPrice({ local: { - price: roomsPriceLocal + parseInt(breakfast.localPrice.totalPrice), - currency: room.localPrice.currency, + amount: roomsPriceLocal + parseInt(breakfast.localPrice.totalPrice), + currency: price.local.currency, }, euro: - room.euroPrice && roomsPriceEuro + price.euro && roomsPriceEuro ? { - price: + amount: roomsPriceEuro + parseInt(breakfast.requestedPrice.totalPrice), - currency: room.euroPrice.currency, + currency: price.euro.currency, } : undefined, }) @@ -120,8 +134,8 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) { bedType, breakfast, roomsPriceLocal, - room.localPrice.currency, - room.euroPrice, + price.local.currency, + price.euro, roomsPriceEuro, setTotalPrice, ]) @@ -151,12 +165,12 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
{room.roomType} - + {intl.formatMessage( { id: "{amount} {currency}" }, { - amount: intl.formatNumber(room.localPrice.price), - currency: room.localPrice.currency, + amount: intl.formatNumber(price.local.amount), + currency: price.local.currency, } )} @@ -229,7 +243,7 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) { {intl.formatMessage( { id: "{amount} {currency}" }, - { amount: "0", currency: room.localPrice.currency } + { amount: "0", currency: price.local.currency } )}
@@ -243,7 +257,7 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) { {intl.formatMessage( { id: "{amount} {currency}" }, - { amount: "0", currency: room.localPrice.currency } + { amount: "0", currency: price.local.currency } )}
@@ -279,22 +293,24 @@ export default function Summary({ showMemberPrice, room }: SummaryProps) {
- - {intl.formatMessage( - { id: "{amount} {currency}" }, - { - amount: intl.formatNumber(totalPrice.local.price), - currency: totalPrice.local.currency, - } - )} - - {totalPrice.euro && ( + {totalPrice.local.amount > 0 && ( + + {intl.formatMessage( + { id: "{amount} {currency}" }, + { + amount: intl.formatNumber(totalPrice.local.amount), + currency: totalPrice.local.currency, + } + )} + + )} + {totalPrice.euro && totalPrice.euro.amount > 0 && ( {intl.formatMessage({ id: "Approx." })}{" "} {intl.formatMessage( { id: "{amount} {currency}" }, { - amount: intl.formatNumber(totalPrice.euro.price), + amount: intl.formatNumber(totalPrice.euro.amount), currency: totalPrice.euro.currency, } )} diff --git a/components/HotelReservation/SelectRate/RoomSelection/utils.ts b/components/HotelReservation/SelectRate/RoomSelection/utils.ts index 43af470e3..d6c54450a 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/utils.ts +++ b/components/HotelReservation/SelectRate/RoomSelection/utils.ts @@ -50,6 +50,7 @@ export function getQueryParamsForEnterDetails( roomTypeCode: room.roomtype, rateCode: room.ratecode, packages: room.packages?.split(",") as RoomPackageCodeEnum[], + counterRateCode: room.counterratecode, })), } } diff --git a/stores/details.ts b/stores/details.ts index a382ad7d7..52e6d41a8 100644 --- a/stores/details.ts +++ b/stores/details.ts @@ -135,8 +135,8 @@ export function createDetailsStore( }, totalPrice: { - euro: { currency: "", price: 0 }, - local: { currency: "", price: 0 }, + euro: { currency: "", amount: 0 }, + local: { currency: "", amount: 0 }, }, }), { diff --git a/types/components/hotelReservation/enterDetails/bookingData.ts b/types/components/hotelReservation/enterDetails/bookingData.ts index 0afabf91a..0683c4739 100644 --- a/types/components/hotelReservation/enterDetails/bookingData.ts +++ b/types/components/hotelReservation/enterDetails/bookingData.ts @@ -7,6 +7,7 @@ interface Room { adults: number roomTypeCode: string rateCode: string + counterRateCode: string children?: Child[] packages?: RoomPackageCodeEnum[] } @@ -18,14 +19,24 @@ export interface BookingData { } type Price = { - price: number + amount: number currency: string } export type RoomsData = { roomType: string - localPrice: Price - euroPrice: Price | undefined + prices: { + public: { + local: Price + euro: Price | undefined + } + member: + | { + local: Price + euro: Price | undefined + } + | undefined + } adults: number children?: Child[] rateDetails?: string[] diff --git a/types/components/hotelReservation/selectRate/section.ts b/types/components/hotelReservation/selectRate/section.ts index 05d86ff6c..eaea36f2e 100644 --- a/types/components/hotelReservation/selectRate/section.ts +++ b/types/components/hotelReservation/selectRate/section.ts @@ -1,4 +1,4 @@ -import { CreditCard } from "@/types/user" +import { CreditCard, SafeUser } from "@/types/user" export interface SectionProps { nextPath: string @@ -28,6 +28,7 @@ export interface BreakfastSelectionProps extends SectionProps { export interface DetailsProps extends SectionProps {} export interface PaymentProps { + user: SafeUser roomPrice: { publicPrice: number; memberPrice: number | undefined } otherPaymentOptions: string[] savedCreditCards: CreditCard[] | null diff --git a/types/components/hotelReservation/selectRate/selectRate.ts b/types/components/hotelReservation/selectRate/selectRate.ts index a1da31b84..12eb83eb1 100644 --- a/types/components/hotelReservation/selectRate/selectRate.ts +++ b/types/components/hotelReservation/selectRate/selectRate.ts @@ -11,7 +11,7 @@ interface Room { adults: number roomtype: string ratecode: string - counterratecode?: string + counterratecode: string child?: Child[] packages?: string } diff --git a/types/stores/details.ts b/types/stores/details.ts index ef6d101dc..d10bb0d61 100644 --- a/types/stores/details.ts +++ b/types/stores/details.ts @@ -8,7 +8,7 @@ export interface DetailsState { actions: { setIsSubmittingDisabled: (isSubmittingDisabled: boolean) => void setTotalPrice: (totalPrice: TotalPrice) => void - toggleSummaryOpen: () => void, + toggleSummaryOpen: () => void updateBedType: (data: BedTypeSchema) => void updateBreakfast: (data: BreakfastPackage | false) => void updateDetails: (data: DetailsSchema) => void @@ -31,10 +31,10 @@ export interface InitialState extends Partial { interface Price { currency: string - price: number + amount: number } export interface TotalPrice { euro: Price | undefined local: Price -} \ No newline at end of file +}