feat: move room charge to top in price details modal

This commit is contained in:
Simon Emanuelsson
2025-05-08 11:28:22 +02:00
committed by Michael Zetterberg
parent 194a401a56
commit a99e434d84
28 changed files with 264 additions and 136 deletions

View File

@@ -9,14 +9,16 @@ import SummaryUI from "./UI"
import type { SummaryProps } from "@/types/components/hotelReservation/summary"
export default function DesktopSummary({ isMember }: SummaryProps) {
const {
booking,
actions: { toggleSummaryOpen },
totalPrice,
vat,
} = useEnterDetailsStore((state) => state)
const toggleSummaryOpen = useEnterDetailsStore(
(state) => state.actions.toggleSummaryOpen
)
const rooms = useEnterDetailsStore((state) => state.rooms)
const { booking, rooms, totalPrice, vat } = useEnterDetailsStore((state) => ({
booking: state.booking,
rooms: state.rooms,
totalPrice: state.totalPrice,
vat: state.vat,
}))
return (
<SidePanel variant="summary">

View File

@@ -12,14 +12,16 @@ import styles from "./mobile.module.css"
import type { SummaryProps } from "@/types/components/hotelReservation/summary"
export default function MobileSummary({ isMember }: SummaryProps) {
const {
booking,
actions: { toggleSummaryOpen },
totalPrice,
vat,
} = useEnterDetailsStore((state) => state)
const toggleSummaryOpen = useEnterDetailsStore(
(state) => state.actions.toggleSummaryOpen
)
const rooms = useEnterDetailsStore((state) => state.rooms)
const { booking, rooms, totalPrice, vat } = useEnterDetailsStore((state) => ({
booking: state.booking,
rooms: state.rooms,
totalPrice: state.totalPrice,
vat: state.vat,
}))
const showPromo =
!isMember &&

View File

@@ -94,7 +94,7 @@ export default function SummaryUI({
? totalPrice.requested.currency === totalPrice.local.currency
: false
const priceDetailsRooms = mapToPrice(rooms, isMember, nights)
const priceDetailsRooms = mapToPrice(rooms, isMember)
const isAllCampaignRate = rooms.every(
(room) => room.room.roomRate.rateDefinition.isCampaignRate
)
@@ -378,7 +378,12 @@ export default function SummaryUI({
<div className={styles.entry}>
<Body color="uiTextHighContrast">
{intl.formatMessage({
defaultMessage: "Breakfast included",
defaultMessage: "Breakfast buffet",
})}
</Body>
<Body color="red">
{intl.formatMessage({
defaultMessage: "Included",
})}
</Body>
</div>

View File

@@ -2,11 +2,7 @@ import { sumPackages } from "@/components/HotelReservation/utils"
import type { RoomState } from "@/types/stores/enter-details"
export function mapToPrice(
rooms: RoomState[],
isMember: boolean,
nights: number
) {
export function mapToPrice(rooms: RoomState[], isMember: boolean) {
return rooms
.filter((room) => room && room.room.roomRate)
.map(({ room }, idx) => {
@@ -26,8 +22,8 @@ export function mapToPrice(
corporateCheque: {
...room.roomRate.corporateCheque.localPrice,
additionalPricePerStay:
(room.roomRate.corporateCheque.localPrice
.additionalPricePerStay || 0) + pkgsSum.price,
room.roomRate.corporateCheque.localPrice
.additionalPricePerStay || 0,
},
},
}
@@ -53,8 +49,8 @@ export function mapToPrice(
redemption: {
...room.roomRate.redemption.localPrice,
additionalPricePerStay:
(room.roomRate.redemption.localPrice.additionalPricePerStay ||
0) + pkgsSum.price,
room.roomRate.redemption.localPrice.additionalPricePerStay ||
0,
},
},
}
@@ -88,12 +84,8 @@ export function mapToPrice(
price: {
regular: {
...room.roomRate.member.localPrice,
pricePerNight:
room.roomRate.member.localPrice.pricePerNight +
pkgsSum.price / nights,
pricePerStay:
room.roomRate.member.localPrice.pricePerStay +
pkgsSum.price,
pricePerNight: room.roomRate.member.localPrice.pricePerNight,
pricePerStay: room.roomRate.member.localPrice.pricePerStay,
},
},
}
@@ -116,11 +108,8 @@ export function mapToPrice(
price: {
regular: {
...room.roomRate.public.localPrice,
pricePerNight:
room.roomRate.public.localPrice.pricePerNight +
pkgsSum.price / nights,
pricePerStay:
room.roomRate.public.localPrice.pricePerStay + pkgsSum.price,
pricePerNight: room.roomRate.public.localPrice.pricePerNight,
pricePerStay: room.roomRate.public.localPrice.pricePerStay,
},
},
}