Merged in fix/SW-3198-prices-select-rate (pull request #2763)
fix(SW-3198): fix striketrhough/regular prices, the same in enter details as select rate * fix(SW-3198): fix striketrhough/regular prices, the same in enter details as select rate * fix(SW-3198): remove additonalcost if calculating cost per room * fix(SW-3198): include bookingcode in specialrate * fix(SW-3198): remove console log * fix(SW-3198): add or operator * fix(SW-3198): capture total return value * fix(SW-3198): rename and move function Approved-by: Joakim Jäderberg Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
@@ -8,7 +8,7 @@ import SummaryUI from "./UI"
|
||||
|
||||
import type { SummaryProps } from "@/types/components/hotelReservation/summary"
|
||||
|
||||
export default function DesktopSummary({ isMember }: SummaryProps) {
|
||||
export default function DesktopSummary({ isUserLoggedIn }: SummaryProps) {
|
||||
const toggleSummaryOpen = useEnterDetailsStore(
|
||||
(state) => state.actions.toggleSummaryOpen
|
||||
)
|
||||
@@ -27,7 +27,7 @@ export default function DesktopSummary({ isMember }: SummaryProps) {
|
||||
<SummaryUI
|
||||
booking={booking}
|
||||
rooms={rooms}
|
||||
isMember={isMember}
|
||||
isUserLoggedIn={isUserLoggedIn}
|
||||
totalPrice={totalPrice}
|
||||
vat={vat}
|
||||
toggleSummaryOpen={toggleSummaryOpen}
|
||||
|
||||
@@ -20,12 +20,12 @@ import styles from "./bottomSheet.module.css"
|
||||
|
||||
interface SummaryBottomSheetProps
|
||||
extends PropsWithChildren<{
|
||||
isMember: boolean
|
||||
isUserLoggedIn: boolean
|
||||
}> {}
|
||||
|
||||
export default function SummaryBottomSheet({
|
||||
children,
|
||||
isMember,
|
||||
isUserLoggedIn,
|
||||
}: SummaryBottomSheetProps) {
|
||||
const intl = useIntl()
|
||||
const scrollY = useRef(0)
|
||||
@@ -68,7 +68,7 @@ export default function SummaryBottomSheet({
|
||||
const containsBookingCodeRate = rooms.find(
|
||||
(r) => r && isBookingCodeRate(r.room.roomRate)
|
||||
)
|
||||
const showDiscounted = containsBookingCodeRate || isMember
|
||||
const showDiscounted = containsBookingCodeRate || isUserLoggedIn
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper} data-open={isSummaryOpen}>
|
||||
@@ -103,13 +103,15 @@ export default function SummaryBottomSheet({
|
||||
</Typography>
|
||||
{showDiscounted && totalPrice.local.regularPrice ? (
|
||||
<Typography variant="Body/Paragraph/mdRegular">
|
||||
<s className={styles.strikeThroughRate}>
|
||||
{formatPrice(
|
||||
intl,
|
||||
totalPrice.local.regularPrice,
|
||||
totalPrice.local.currency
|
||||
)}
|
||||
</s>
|
||||
<p>
|
||||
<s className={styles.strikeThroughRate}>
|
||||
{formatPrice(
|
||||
intl,
|
||||
totalPrice.local.regularPrice,
|
||||
totalPrice.local.currency
|
||||
)}
|
||||
</s>
|
||||
</p>
|
||||
</Typography>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import styles from "./mobile.module.css"
|
||||
|
||||
import type { SummaryProps } from "@/types/components/hotelReservation/summary"
|
||||
|
||||
export default function MobileSummary({ isMember }: SummaryProps) {
|
||||
export default function MobileSummary({ isUserLoggedIn }: SummaryProps) {
|
||||
const { isSummaryOpen, toggleSummaryOpen } = useEnterDetailsStore(
|
||||
(state) => ({
|
||||
isSummaryOpen: state.isSummaryOpen,
|
||||
@@ -29,7 +29,7 @@ export default function MobileSummary({ isMember }: SummaryProps) {
|
||||
}))
|
||||
|
||||
const showPromo =
|
||||
!isMember &&
|
||||
!isUserLoggedIn &&
|
||||
rooms.length === 1 &&
|
||||
!rooms[0].room.guest.join &&
|
||||
!rooms[0].room.guest.membershipNo
|
||||
@@ -51,12 +51,12 @@ export default function MobileSummary({ isMember }: SummaryProps) {
|
||||
/>
|
||||
)}
|
||||
|
||||
<SummaryBottomSheet isMember={isMember}>
|
||||
<SummaryBottomSheet isUserLoggedIn={isUserLoggedIn}>
|
||||
<div className={styles.wrapper}>
|
||||
<SummaryUI
|
||||
booking={booking}
|
||||
rooms={rooms}
|
||||
isMember={isMember}
|
||||
isUserLoggedIn={isUserLoggedIn}
|
||||
totalPrice={totalPrice}
|
||||
vat={vat}
|
||||
toggleSummaryOpen={toggleSummaryOpen}
|
||||
|
||||
@@ -12,7 +12,6 @@ import { ChildBedMapEnum } from "@scandic-hotels/trpc/enums/childBedMapEnum"
|
||||
|
||||
import { getFeatureDescription } from "@/components/HotelReservation/utils/getRoomFeatureDescription"
|
||||
|
||||
import { getMemberPrice, getPublicPrice } from "../utils"
|
||||
import Breakfast from "./Breakfast"
|
||||
|
||||
import styles from "./room.module.css"
|
||||
@@ -23,8 +22,7 @@ interface RoomProps {
|
||||
room: RoomType
|
||||
roomNumber: number
|
||||
roomCount: number
|
||||
isMember: boolean
|
||||
isSpecialRate: boolean
|
||||
isUserLoggedIn: boolean
|
||||
nightsCount: number
|
||||
defaultCurrency: CurrencyEnum
|
||||
}
|
||||
@@ -33,8 +31,7 @@ export default function Room({
|
||||
room,
|
||||
roomNumber,
|
||||
roomCount,
|
||||
isMember,
|
||||
isSpecialRate,
|
||||
isUserLoggedIn,
|
||||
nightsCount,
|
||||
defaultCurrency,
|
||||
}: RoomProps) {
|
||||
@@ -61,16 +58,23 @@ export default function Room({
|
||||
const childBedCrib = childrenBeds?.get(ChildBedMapEnum.IN_CRIB)
|
||||
const childBedExtraBed = childrenBeds?.get(ChildBedMapEnum.IN_EXTRA_BED)
|
||||
|
||||
const memberPrice = getMemberPrice(room.roomRate)
|
||||
const publicPrice = getPublicPrice(room.roomRate)
|
||||
|
||||
const isFirstRoomMember = roomNumber === 1 && isMember
|
||||
const isFirstRoomMember = roomNumber === 1 && isUserLoggedIn
|
||||
const isOrWillBecomeMember = !!(
|
||||
room.guest.join ||
|
||||
room.guest.membershipNo ||
|
||||
isFirstRoomMember
|
||||
)
|
||||
const showMemberPrice = !!(isOrWillBecomeMember && memberPrice)
|
||||
const showMemberPrice = !!(
|
||||
isOrWillBecomeMember &&
|
||||
"member" in room.roomRate &&
|
||||
room.roomRate.member
|
||||
)
|
||||
const isSpecialRate =
|
||||
"corporateCheque" in room.roomRate ||
|
||||
"redemption" in room.roomRate ||
|
||||
"voucher" in room.roomRate ||
|
||||
room.roomRate.bookingCode ||
|
||||
room.roomRate.rateDefinition.isCampaignRate
|
||||
const showDiscounted = isSpecialRate || showMemberPrice
|
||||
|
||||
const adultsMsg = intl.formatMessage(
|
||||
@@ -94,7 +98,7 @@ export default function Room({
|
||||
|
||||
let rateDetails = room.rateDetails
|
||||
if (room.memberRateDetails) {
|
||||
if (isMember || room.guest.join) {
|
||||
if (showMemberPrice) {
|
||||
rateDetails = room.memberRateDetails
|
||||
}
|
||||
}
|
||||
@@ -102,15 +106,13 @@ export default function Room({
|
||||
const guests = guestsParts.join(", ")
|
||||
const zeroPrice = formatPrice(intl, 0, defaultCurrency)
|
||||
|
||||
let price = showMemberPrice
|
||||
? formatPrice(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
|
||||
)
|
||||
let price = formatPrice(
|
||||
intl,
|
||||
room.roomPrice.perStay.local.price,
|
||||
room.roomPrice.perStay.local.currency,
|
||||
room.roomPrice.perStay.local.additionalPrice,
|
||||
room.roomPrice.perStay.local.additionalPriceCurrency
|
||||
)
|
||||
|
||||
let currency: string = room.roomPrice.perStay.local.currency
|
||||
const isVoucher = "voucher" in room.roomRate
|
||||
@@ -164,12 +166,12 @@ export default function Room({
|
||||
>
|
||||
{price}
|
||||
</p>
|
||||
{showDiscounted && publicPrice ? (
|
||||
{showDiscounted && room.roomPrice.perStay.local.regularPrice ? (
|
||||
<s className={styles.strikeThroughRate}>
|
||||
{formatPrice(
|
||||
intl,
|
||||
publicPrice.amount,
|
||||
publicPrice.currency
|
||||
room.roomPrice.perStay.local.regularPrice,
|
||||
currency
|
||||
)}
|
||||
</s>
|
||||
) : null}
|
||||
|
||||
@@ -32,7 +32,7 @@ export default function SummaryUI({
|
||||
booking,
|
||||
rooms,
|
||||
totalPrice,
|
||||
isMember,
|
||||
isUserLoggedIn,
|
||||
vat,
|
||||
toggleSummaryOpen,
|
||||
defaultCurrency,
|
||||
@@ -59,7 +59,7 @@ export default function SummaryUI({
|
||||
const roomOneGuest = rooms[0].room.guest
|
||||
const showSignupPromo =
|
||||
rooms.length === 1 &&
|
||||
!isMember &&
|
||||
!isUserLoggedIn &&
|
||||
!roomOneGuest.membershipNo &&
|
||||
!roomOneGuest.join
|
||||
|
||||
@@ -67,13 +67,8 @@ export default function SummaryUI({
|
||||
|
||||
const roomOneRoomRate = rooms[0].room.roomRate
|
||||
const isVoucherRate = "voucher" in roomOneRoomRate
|
||||
// In case of Redemption, voucher and Corporate cheque do not show approx price
|
||||
const isSpecialRate =
|
||||
"corporateCheque" in roomOneRoomRate ||
|
||||
"redemption" in roomOneRoomRate ||
|
||||
isVoucherRate
|
||||
|
||||
const priceDetailsRooms = mapToPrice(rooms, isMember)
|
||||
const priceDetailsRooms = mapToPrice(rooms, isUserLoggedIn)
|
||||
const isAllCampaignRate = rooms.every(
|
||||
(room) => room.room.roomRate.rateDefinition.isCampaignRate
|
||||
)
|
||||
@@ -83,7 +78,7 @@ export default function SummaryUI({
|
||||
const containsBookingCodeRate = rooms.find(
|
||||
(r) => r && isBookingCodeRate(r.room.roomRate)
|
||||
)
|
||||
const showDiscounted = containsBookingCodeRate || isMember
|
||||
const showDiscounted = containsBookingCodeRate || isUserLoggedIn
|
||||
|
||||
const totalCurrency = isVoucherRate
|
||||
? CurrencyEnum.Voucher
|
||||
@@ -127,8 +122,7 @@ export default function SummaryUI({
|
||||
room={room}
|
||||
roomNumber={idx + 1}
|
||||
roomCount={rooms.length}
|
||||
isMember={isMember}
|
||||
isSpecialRate={isSpecialRate}
|
||||
isUserLoggedIn={isUserLoggedIn}
|
||||
nightsCount={nights}
|
||||
/>
|
||||
))}
|
||||
@@ -192,13 +186,15 @@ export default function SummaryUI({
|
||||
</Typography>
|
||||
{showDiscounted && totalPrice.local.regularPrice ? (
|
||||
<Typography variant="Body/Paragraph/mdRegular">
|
||||
<s className={styles.strikeThroughRate}>
|
||||
{formatPrice(
|
||||
intl,
|
||||
totalPrice.local.regularPrice,
|
||||
totalPrice.local.currency
|
||||
)}
|
||||
</s>
|
||||
<p>
|
||||
<s className={styles.strikeThroughRate}>
|
||||
{formatPrice(
|
||||
intl,
|
||||
totalPrice.local.regularPrice,
|
||||
totalPrice.local.currency
|
||||
)}
|
||||
</s>
|
||||
</p>
|
||||
</Typography>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -223,7 +219,7 @@ export default function SummaryUI({
|
||||
alignCenter
|
||||
/>
|
||||
<Divider className={styles.bottomDivider} color="Border/Divider/Subtle" />
|
||||
{showSignupPromo && roomOneMemberPrice && !isMember ? (
|
||||
{showSignupPromo && roomOneMemberPrice && !isUserLoggedIn ? (
|
||||
<SignupPromoDesktop
|
||||
memberPrice={roomOneMemberPrice}
|
||||
badgeContent={"✌️"}
|
||||
|
||||
Reference in New Issue
Block a user