diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx index e15b6924e..6e63da60a 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx @@ -30,6 +30,8 @@ export default function PriceDetails() { .startOf("day") .diff(dt(fromDate).startOf("day"), "days") + console.log({ rooms }) + const totalPrice = rooms.reduce( (total, room) => { if (!room) { diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx index 003b7a17a..216194384 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx @@ -210,17 +210,17 @@ export default function SummaryUI({ {showMemberPrice ? formatPrice( - intl, - memberPrice.amount, - memberPrice.currency - ) + intl, + memberPrice.amount, + memberPrice.currency + ) : formatPrice( - intl, - room.roomPrice.perStay.local.price, - room.roomPrice.perStay.local.currency, - room.roomPrice.perStay.local.additionalPrice, - room.roomPrice.perStay.local.additionalPriceCurrency - )} + intl, + room.roomPrice.perStay.local.price, + room.roomPrice.perStay.local.currency, + room.roomPrice.perStay.local.additionalPrice, + room.roomPrice.perStay.local.additionalPriceCurrency + )} @@ -272,22 +272,22 @@ export default function SummaryUI({ {room.roomFeatures ? room.roomFeatures.map((feature) => ( -
-
- - {feature.description} - -
- +
+
- {formatPrice( - intl, - feature.localPrice.price, - feature.localPrice.currency - )} + {feature.description}
- )) + + + {formatPrice( + intl, + feature.localPrice.price, + feature.localPrice.currency + )} + +
+ )) : null} {room.bedType ? (
diff --git a/apps/scandic-web/components/HotelReservation/MyStay/MultiRoom/PriceType.tsx b/apps/scandic-web/components/HotelReservation/MyStay/MultiRoom/PriceType.tsx new file mode 100644 index 000000000..6ff89815c --- /dev/null +++ b/apps/scandic-web/components/HotelReservation/MyStay/MultiRoom/PriceType.tsx @@ -0,0 +1,62 @@ +"use client" +import { useIntl } from "react-intl" + +import { Typography } from "@scandic-hotels/design-system/Typography" + +import Cheques from "../Cheques" +import Points from "../Points" +import Price from "../Price" + +import { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay" +import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" + +interface PriceTypeProps + extends Pick< + BookingConfirmation["booking"], + "cheques" | "rateDefinition" | "roomPoints" | "totalPrice" | "vouchers" + > { + isCancelled: boolean + priceType: PriceTypeEnum +} + +export default function PriceType({ + cheques, + isCancelled, + priceType, + rateDefinition, + roomPoints, + totalPrice, + vouchers, +}: PriceTypeProps) { + const intl = useIntl() + + switch (priceType) { + case PriceTypeEnum.cheque: + return + case PriceTypeEnum.money: + return ( + + ) + case PriceTypeEnum.points: + return + case PriceTypeEnum.voucher: + return ( + +

+ {intl.formatMessage( + { + defaultMessage: "{count} voucher", + }, + { count: vouchers } + )} +

+
+ ) + default: + return null + } +} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/MultiRoom/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/MultiRoom/index.tsx index ad70490a4..6f2cf7363 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/MultiRoom/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/MultiRoom/index.tsx @@ -16,11 +16,11 @@ import IconChip from "@/components/TempDesignSystem/IconChip" import useLang from "@/hooks/useLang" import { IconForFeatureCode } from "../../utils" -import PriceType from "../PriceType" import { hasModifiableRate } from "../utils" import { hasBreakfastPackageFromBookingFlow } from "../utils/hasBreakfastPackage" import { mapRoomDetails } from "../utils/mapRoomDetails" import MultiRoomSkeleton from "./MultiRoomSkeleton" +import PriceType from "./PriceType" import ToggleSidePeek from "./ToggleSidePeek" import styles from "./multiRoom.module.css" @@ -33,10 +33,10 @@ import type { User } from "@/types/user" interface MultiRoomProps { booking?: BookingConfirmation["booking"] room?: - | (Room & { - bedType: Room["roomTypes"][number] - }) - | null + | (Room & { + bedType: Room["roomTypes"][number] + }) + | null bookingPromise?: Promise index?: number user: User | null @@ -243,26 +243,26 @@ export default function MultiRoom({ item.code as RoomPackageCodeEnum ) ) && ( -
- {packages - .filter((item) => - Object.values(RoomPackageCodeEnum).includes( - item.code as RoomPackageCodeEnum +
+ {packages + .filter((item) => + Object.values(RoomPackageCodeEnum).includes( + item.code as RoomPackageCodeEnum + ) ) - ) - .map((item) => { - return ( - - - - ) - })} -
- )} + .map((item) => { + return ( + + + + ) + })} +
+ )}
diff --git a/apps/scandic-web/components/HotelReservation/MyStay/SingleRoom/PriceType.tsx b/apps/scandic-web/components/HotelReservation/MyStay/SingleRoom/PriceType.tsx new file mode 100644 index 000000000..f16f0b9a1 --- /dev/null +++ b/apps/scandic-web/components/HotelReservation/MyStay/SingleRoom/PriceType.tsx @@ -0,0 +1,63 @@ +"use client" +import { useIntl } from "react-intl" + +import { Typography } from "@scandic-hotels/design-system/Typography" + +import { useMyStayRoomDetailsStore } from "@/stores/my-stay/myStayRoomDetailsStore" + +import Cheques from "../Cheques" +import Points from "../Points" +import Price from "../Price" + +import { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay" + +export default function PriceType() { + const intl = useIntl() + const { + cheques, + isCancelled, + priceType, + rateDefinition, + roomPoints, + totalPrice, + vouchers, + } = useMyStayRoomDetailsStore((state) => ({ + cheques: state.bookedRoom.cheques, + isCancelled: state.bookedRoom.isCancelled, + priceType: state.bookedRoom.priceType, + rateDefinition: state.bookedRoom.rateDefinition, + roomPoints: state.bookedRoom.roomPoints, + totalPrice: state.bookedRoom.totalPrice, + vouchers: state.bookedRoom.vouchers, + })) + + switch (priceType) { + case PriceTypeEnum.cheque: + return + case PriceTypeEnum.money: + return ( + + ) + case PriceTypeEnum.points: + return + case PriceTypeEnum.voucher: + return ( + +

+ {intl.formatMessage( + { + defaultMessage: "{count} voucher", + }, + { count: vouchers } + )} +

+
+ ) + default: + return null + } +} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/SingleRoom/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/SingleRoom/index.tsx index 5585c84dd..6f98fa4e4 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/SingleRoom/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/SingleRoom/index.tsx @@ -18,8 +18,8 @@ import { formatPrice } from "@/utils/numberFormatting" import GuestDetails from "../GuestDetails" import PriceDetails from "../PriceDetails" -import PriceType from "../PriceType" import { hasModifiableRate } from "../utils" +import PriceType from "./PriceType" import ToggleSidePeek from "./ToggleSidePeek" import styles from "./room.module.css" @@ -119,14 +119,14 @@ export function SingleRoom({ bedType, image, hotel, user }: RoomProps) { const breakfastText = rateDefinition.breakfastIncluded ? intl.formatMessage({ - defaultMessage: "Included", - }) + defaultMessage: "Included", + }) : breakfast ? formatPrice( - intl, - breakfast.localPrice.totalPrice, - breakfast.localPrice.currency - ) + intl, + breakfast.localPrice.totalPrice, + breakfast.localPrice.currency + ) : null return ( @@ -183,26 +183,26 @@ export function SingleRoom({ bedType, image, hotel, user }: RoomProps) { item.code as RoomPackageCodeEnum ) ) && ( -
- {packages - .filter((item) => - Object.values(RoomPackageCodeEnum).includes( - item.code as RoomPackageCodeEnum +
+ {packages + .filter((item) => + Object.values(RoomPackageCodeEnum).includes( + item.code as RoomPackageCodeEnum + ) ) - ) - .map((item) => { - return ( - - - - ) - })} -
- )} + .map((item) => { + return ( + + + + ) + })} +
+ )}
{bedType.mainBed.description} {bedType.mainBed.widthRange.min === - bedType.mainBed.widthRange.max + bedType.mainBed.widthRange.max ? // eslint-disable-next-line formatjs/no-literal-string-in-jsx - ` (${mainBedWidthValueMsg})` + ` (${mainBedWidthValueMsg})` : // eslint-disable-next-line formatjs/no-literal-string-in-jsx - ` (${mainBedWidthRangeMsg})`} + ` (${mainBedWidthRangeMsg})`}

diff --git a/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/Row/Price/Voucher.tsx b/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/Row/Price/Voucher.tsx index e914a04ae..ad85c6052 100644 --- a/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/Row/Price/Voucher.tsx +++ b/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/Row/Price/Voucher.tsx @@ -53,7 +53,7 @@ export default function VoucherPrice({ let averagePricePerNight = `${price.numberOfVouchers} ${CurrencyEnum.Voucher}` if (averageAdditionalPricePerNight) { - averagePricePerNight = `${averagePricePerNight} + ${averageAdditionalPricePerNight} ${pkgsSum.currency}` + averagePricePerNight = `${averagePricePerNight} + ${averageAdditionalPricePerNight} ${pkgsSum.currency ?? currency}` } return ( @@ -68,7 +68,7 @@ export default function VoucherPrice({ price.numberOfVouchers, CurrencyEnum.Voucher, additionalPricePerStay, - pkgsSum.currency + pkgsSum.currency ?? currency )} />