fix: unite all price details modals to one and align on ui
This commit is contained in:
committed by
Michael Zetterberg
parent
8152aea649
commit
1f94c581ae
@@ -1,36 +0,0 @@
|
||||
.priceDetailsTable {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.price {
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.tableSection {
|
||||
display: flex;
|
||||
gap: var(--Spacing-x-half);
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tableSection:has(tr > th) {
|
||||
padding-top: var(--Spacing-x2);
|
||||
}
|
||||
|
||||
.tableSection:has(tr > th):not(:first-of-type) {
|
||||
border-top: 1px solid var(--Primary-Light-On-Surface-Divider-subtle);
|
||||
}
|
||||
|
||||
.tableSection:not(:last-child) {
|
||||
padding-bottom: var(--Spacing-x2);
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
@media screen and (min-width: 768px) {
|
||||
.priceDetailsTable {
|
||||
min-width: 512px;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { Button } from "@scandic-hotels/design-system/Button"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
|
||||
import { dt } from "@/lib/dt"
|
||||
import { useRatesStore } from "@/stores/select-rate"
|
||||
|
||||
import PriceDetailsModal from "@/components/HotelReservation/PriceDetailsModal"
|
||||
import SignupPromoDesktop from "@/components/HotelReservation/SignupPromo/Desktop"
|
||||
@@ -18,7 +19,7 @@ import useLang from "@/hooks/useLang"
|
||||
import { formatPrice } from "@/utils/numberFormatting"
|
||||
|
||||
import { isBookingCodeRate } from "./isBookingCodeRate"
|
||||
import PriceDetailsTable from "./PriceDetailsTable"
|
||||
import { mapToPrice } from "./mapToPrice"
|
||||
|
||||
import styles from "./summary.module.css"
|
||||
|
||||
@@ -34,6 +35,7 @@ export default function Summary({
|
||||
vat,
|
||||
toggleSummaryOpen,
|
||||
}: SelectRateSummaryProps) {
|
||||
const rateSummary = useRatesStore((state) => state.rateSummary)
|
||||
const intl = useIntl()
|
||||
const lang = useLang()
|
||||
|
||||
@@ -66,6 +68,8 @@ export default function Summary({
|
||||
)
|
||||
const showDiscounted = containsBookingCodeRate || isMember
|
||||
|
||||
const priceDetailsRooms = mapToPrice(rateSummary, booking, isMember)
|
||||
|
||||
return (
|
||||
<section className={styles.summary}>
|
||||
<header className={styles.header}>
|
||||
@@ -304,17 +308,14 @@ export default function Summary({
|
||||
{ b: (str) => <b>{str}</b> }
|
||||
)}
|
||||
</Body>
|
||||
<PriceDetailsModal>
|
||||
<PriceDetailsTable
|
||||
bookingCode={booking.bookingCode}
|
||||
fromDate={booking.fromDate}
|
||||
isMember={isMember}
|
||||
rooms={rooms}
|
||||
toDate={booking.toDate}
|
||||
totalPrice={totalPrice}
|
||||
vat={vat}
|
||||
/>
|
||||
</PriceDetailsModal>
|
||||
<PriceDetailsModal
|
||||
bookingCode={booking.bookingCode}
|
||||
fromDate={booking.fromDate}
|
||||
rooms={priceDetailsRooms}
|
||||
toDate={booking.toDate}
|
||||
totalPrice={totalPrice}
|
||||
vat={vat}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Body
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import type {
|
||||
Rate,
|
||||
SelectRateSearchParams,
|
||||
} from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import type { Room } from "@/components/HotelReservation/PriceDetailsModal/PriceDetailsTable"
|
||||
|
||||
export function mapToPrice(
|
||||
rooms: (Rate | null)[],
|
||||
booking: SelectRateSearchParams,
|
||||
isUserLoggedIn: boolean
|
||||
) {
|
||||
return rooms
|
||||
.map((room, idx) => {
|
||||
if (!room) {
|
||||
return null
|
||||
}
|
||||
|
||||
let price = null
|
||||
if ("corporateCheque" in room.product) {
|
||||
price = {
|
||||
corporateCheque: room.product.corporateCheque.localPrice,
|
||||
}
|
||||
} else if ("redemption" in room.product) {
|
||||
price = {
|
||||
redemption: room.product.redemption.localPrice,
|
||||
}
|
||||
} else if ("voucher" in room.product) {
|
||||
price = {
|
||||
voucher: room.product.voucher,
|
||||
}
|
||||
} else {
|
||||
const isMainRoom = idx === 0
|
||||
const memberRate = room.product.member
|
||||
const onlyMemberRate = !room.product.public && memberRate
|
||||
if ((isUserLoggedIn && isMainRoom && memberRate) || onlyMemberRate) {
|
||||
price = {
|
||||
regular: memberRate.localPrice,
|
||||
}
|
||||
} else if (room.product.public) {
|
||||
price = {
|
||||
regular: room.product.public.localPrice,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bookingRoom = booking.rooms[idx]
|
||||
return {
|
||||
adults: bookingRoom.adults,
|
||||
bedType: undefined,
|
||||
breakfast: undefined,
|
||||
breakfastIncluded: room.product.rateDefinition.breakfastIncluded,
|
||||
childrenInRoom: bookingRoom.childrenInRoom,
|
||||
packages: room.packages,
|
||||
price,
|
||||
roomType: room.roomType,
|
||||
}
|
||||
})
|
||||
.filter((r) => !!(r && r.price)) as Room[]
|
||||
}
|
||||
Reference in New Issue
Block a user