fix: unite all price details modals to one and align on ui

This commit is contained in:
Simon Emanuelsson
2025-04-15 15:04:11 +02:00
committed by Michael Zetterberg
parent 8152aea649
commit 1f94c581ae
54 changed files with 1926 additions and 746 deletions

View File

@@ -11,6 +11,7 @@ import {
type RoomPackageCodes,
} from "@/types/components/hotelReservation/selectRate/roomFilter"
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
import type { Packages } from "@/types/requests/packages"
interface IconForFeatureCodeProps {
featureCode: RoomPackageCodes
@@ -53,3 +54,41 @@ export function generateChildrenString(children: Child[]): string {
})
.join(",")}]`
}
export function sumPackages(packages: Packages | null) {
if (!packages || !packages.length) {
return {
currency: undefined,
price: 0,
}
}
return packages.reduce(
(total, pkg) => {
total.price = total.price + pkg.localPrice.totalPrice
return total
},
{
currency: packages[0].localPrice.currency,
price: 0,
}
)
}
export function sumPackagesRequestedPrice(packages: Packages | null) {
if (!packages || !packages.length) {
return {
currency: undefined,
price: 0,
}
}
return packages.reduce(
(total, pkg) => {
total.price = total.price + pkg.requestedPrice.totalPrice
return total
},
{
currency: packages[0].requestedPrice.currency,
price: 0,
}
)
}