fix (SW-1352): update PriceDetailsTable with avarage price per night
This commit is contained in:
@@ -8,7 +8,6 @@ import { useEnterDetailsStore } from "@/stores/enter-details"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||
import useLang from "@/hooks/useLang"
|
||||
import { getNights } from "@/utils/dateFormatting"
|
||||
import { formatPrice } from "@/utils/numberFormatting"
|
||||
|
||||
import styles from "./priceDetailsTable.module.css"
|
||||
@@ -16,14 +15,22 @@ import styles from "./priceDetailsTable.module.css"
|
||||
import { type PriceDetailsTableProps } from "@/types/components/hotelReservation/enterDetails/priceDetailsTable"
|
||||
import type { DetailsState } from "@/types/stores/enter-details"
|
||||
|
||||
function Row({ label, value }: { label: string; value: string }) {
|
||||
function Row({
|
||||
label,
|
||||
value,
|
||||
bold,
|
||||
}: {
|
||||
label: string
|
||||
value: string
|
||||
bold?: boolean
|
||||
}) {
|
||||
return (
|
||||
<tr className={styles.row}>
|
||||
<td>
|
||||
<Caption>{label}</Caption>
|
||||
<Caption type={bold ? "bold" : undefined}>{label}</Caption>
|
||||
</td>
|
||||
<td className={styles.price}>
|
||||
<Caption>{value}</Caption>
|
||||
<Caption type={bold ? "bold" : undefined}>{value}</Caption>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
@@ -33,11 +40,18 @@ function TableSection({ children }: React.PropsWithChildren) {
|
||||
return <tbody className={styles.tableSection}>{children}</tbody>
|
||||
}
|
||||
|
||||
function TableSectionHeader({ title }: { title: string }) {
|
||||
function TableSectionHeader({
|
||||
title,
|
||||
subtitle,
|
||||
}: {
|
||||
title: string
|
||||
subtitle?: string
|
||||
}) {
|
||||
return (
|
||||
<tr>
|
||||
<th colSpan={2}>
|
||||
<Body>{title}</Body>
|
||||
{subtitle ? <Body>{subtitle}</Body> : null}
|
||||
</th>
|
||||
</tr>
|
||||
)
|
||||
@@ -67,54 +81,58 @@ export default function PriceDetailsTable({
|
||||
|
||||
// TODO: Update for Multiroom later
|
||||
const { adults, childrenInRoom } = booking.rooms[0]
|
||||
const nights = getNights(booking.fromDate, booking.toDate)
|
||||
|
||||
const diff = dt(booking.toDate).diff(booking.fromDate, "days")
|
||||
const nights = intl.formatMessage(
|
||||
{ id: "booking.nights" },
|
||||
{ totalNights: diff }
|
||||
)
|
||||
const vatPercentage = vat / 100
|
||||
const vatAmount = totalPrice.local.price * vatPercentage
|
||||
|
||||
const priceExclVat = totalPrice.local.price - vatAmount
|
||||
|
||||
const duration = ` ${dt(booking.fromDate).locale(lang).format("ddd, D MMM")}
|
||||
-
|
||||
${dt(booking.toDate).locale(lang).format("ddd, D MMM")} (${nights})`
|
||||
return (
|
||||
<table className={styles.priceDetailsTable}>
|
||||
<TableSection>
|
||||
<TableSectionHeader title={roomType} />
|
||||
{nights.map((night) => {
|
||||
return (
|
||||
<Row
|
||||
key={night.format("YYMMDD")}
|
||||
label={dt(night).locale(lang).format("ddd, D MMM YYYY")}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
roomPrice.perNight.local.price,
|
||||
roomPrice.perNight.local.currency
|
||||
)}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</TableSection>
|
||||
{bedType ? (
|
||||
<TableSection>
|
||||
<TableSectionHeader title={roomType} subtitle={duration} />
|
||||
<Row
|
||||
label={intl.formatMessage({ id: "Average price per night" })}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
roomPrice.perNight.local.price,
|
||||
roomPrice.perNight.local.currency
|
||||
)}
|
||||
/>
|
||||
{bedType ? (
|
||||
<Row
|
||||
label={bedType.description}
|
||||
value={formatPrice(intl, 0, roomPrice.perStay.local.currency)}
|
||||
/>
|
||||
</TableSection>
|
||||
) : null}
|
||||
) : null}
|
||||
<Row
|
||||
bold
|
||||
label={intl.formatMessage({ id: "Room charge" })}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
roomPrice.perStay.local.price,
|
||||
roomPrice.perStay.local.currency
|
||||
)}
|
||||
/>
|
||||
</TableSection>
|
||||
|
||||
{breakfast ? (
|
||||
<TableSection>
|
||||
<TableSectionHeader title={intl.formatMessage({ id: "Breakfast" })} />
|
||||
<Row
|
||||
label={`${intl.formatMessage(
|
||||
label={intl.formatMessage(
|
||||
{
|
||||
id: "{totalAdults, plural, one {# voksen} other {# voksne}}",
|
||||
id: "Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}",
|
||||
},
|
||||
{ totalAdults: adults }
|
||||
)}, ${intl.formatMessage(
|
||||
{
|
||||
id: "{totalBreakfasts, plural, one {# morgenmad} other {# morgenmad}}",
|
||||
},
|
||||
{ totalBreakfasts: nights.length }
|
||||
)}`}
|
||||
{ totalAdults: adults, totalBreakfasts: diff }
|
||||
)}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
parseInt(breakfast.localPrice.totalPrice),
|
||||
@@ -123,20 +141,26 @@ export default function PriceDetailsTable({
|
||||
/>
|
||||
{childrenInRoom?.length ? (
|
||||
<Row
|
||||
label={`${intl.formatMessage(
|
||||
label={intl.formatMessage(
|
||||
{
|
||||
id: "{totalChildren, plural, one {# child} other {# children}}",
|
||||
id: "Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
||||
},
|
||||
{ totalChildren: childrenInRoom.length }
|
||||
)}, ${intl.formatMessage(
|
||||
{
|
||||
id: "{totalBreakfasts, plural, one {# breakfast} other {# breakfasts}}",
|
||||
},
|
||||
{ totalBreakfasts: nights.length }
|
||||
)}`}
|
||||
{ totalChildren: childrenInRoom.length, totalBreakfasts: diff }
|
||||
)}
|
||||
value={formatPrice(intl, 0, breakfast.localPrice.currency)}
|
||||
/>
|
||||
) : null}
|
||||
<Row
|
||||
bold
|
||||
label={intl.formatMessage({
|
||||
id: "Breakfast charge",
|
||||
})}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
parseInt(breakfast.localPrice.totalPrice),
|
||||
breakfast.localPrice.currency
|
||||
)}
|
||||
/>
|
||||
</TableSection>
|
||||
) : null}
|
||||
<TableSection>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"At latest": "Senest",
|
||||
"At the hotel": "På hotellet",
|
||||
"Attractions": "Attraktioner",
|
||||
"Average price per night": "gennemsnitspris pr. nat",
|
||||
"Away from elevator": "Væk fra elevator",
|
||||
"Back to scandichotels.com": "Tilbage til scandichotels.com",
|
||||
"Back to top": "Tilbage til top",
|
||||
@@ -62,12 +63,15 @@
|
||||
"Booking number": "Bookingnummer",
|
||||
"Breakfast": "Morgenmad",
|
||||
"Breakfast buffet": "Morgenbuffet",
|
||||
"Breakfast charge": "Morgenmadsgebyr",
|
||||
"Breakfast deal can be purchased at the hotel.": "Morgenmad kan købes på hotellet.",
|
||||
"Breakfast excluded": "Morgenmad ikke inkluderet",
|
||||
"Breakfast included": "Morgenmad inkluderet",
|
||||
"Breakfast is included.": "Morgenmad er inkluderet.",
|
||||
"Breakfast restaurant": "Breakfast restaurant",
|
||||
"Breakfast selection in next step.": "Valg af morgenmad i næste trin.",
|
||||
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}": "Morgenmad ({totalAdults, plural, one {# voksen} other {# voksne}}) x {totalBreakfasts}",
|
||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}": "Morgenmad ({totalChildren, plural, one {# barn} other {# børn}}) x {totalBreakfasts}",
|
||||
"Bus terminal": "Busstation",
|
||||
"Business": "Forretning",
|
||||
"By accepting the <termsAndConditionsLink>Terms and Conditions for Scandic Friends</termsAndConditionsLink> I understand that my personal data will be processed in accordance with <privacyPolicy>Scandic's Privacy Policy</privacyPolicy>.": "Ved at acceptere <termsAndConditionsLink>vilkårene og betingelserne for Scandic Friends</termsAndConditionsLink>, forstår jeg, at mine personlige oplysninger vil blive behandlet i overensstemmelse med <privacyPolicy>Scandics privatlivspolitik</privacyPolicy>.",
|
||||
@@ -365,6 +369,7 @@
|
||||
"Restaurants & Bars": "Restaurants & Bars",
|
||||
"Retype new password": "Gentag den nye adgangskode",
|
||||
"Room & Terms": "Værelse & Vilkår",
|
||||
"Room charge": "Værelsesafgift",
|
||||
"Room facilities": "Værelsesfaciliteter",
|
||||
"Rooms": "Værelser",
|
||||
"Rooms & Guests": "Værelser & gæster",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"At latest": "Spätestens",
|
||||
"At the hotel": "Im Hotel",
|
||||
"Attraction": "Attraktion",
|
||||
"Average price per night": "Durchschnittspreis pro Nacht",
|
||||
"Away from elevator": "Weg vom Aufzug",
|
||||
"Back to scandichotels.com": "Zurück zu scandichotels.com",
|
||||
"Back to top": "Zurück zur Spitze",
|
||||
@@ -62,13 +63,15 @@
|
||||
"Booking number": "Buchungsnummer",
|
||||
"Breakfast": "Frühstück",
|
||||
"Breakfast buffet": "Frühstücksbuffet",
|
||||
"Breakfast charge": "Frühstücksgebühr",
|
||||
"Breakfast deal can be purchased at the hotel.": "Frühstücksangebot kann im Hotel gekauft werden.",
|
||||
"Breakfast excluded": "Frühstück nicht inbegriffen",
|
||||
"Breakfast included": "Frühstück inbegriffen",
|
||||
"Breakfast is included.": "Frühstück ist inbegriffen.",
|
||||
"Breakfast restaurant": "Breakfast restaurant",
|
||||
"Breakfast selection in next step.": "Frühstücksauswahl in nächsten Schritt.",
|
||||
"Bus terminal": "Busbahnhof",
|
||||
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}": "Frühstück ({totalAdults, plural, one {# erwachsene} other {# erwachsene}}) x {totalBreakfasts}",
|
||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}": "Frühstück ({totalChildren, plural, one {# kind} other {# kinder}}) x {totalBreakfasts}",
|
||||
"Business": "Geschäft",
|
||||
"By accepting the <termsAndConditionsLink>Terms and Conditions for Scandic Friends</termsAndConditionsLink> I understand that my personal data will be processed in accordance with <privacyPolicy>Scandic's Privacy Policy</privacyPolicy>.": "Mit der Annahme der <termsAndConditionsLink>Allgemeinen Geschäftsbedingungen für Scandic Friends</termsAndConditionsLink> erkläre ich mich damit einverstanden, dass meine persönlichen Daten in Übereinstimmung mit der <privacyPolicy>Datenschutzrichtlinie von Scandic verarbeitet werden</privacyPolicy>.",
|
||||
"By paying with any of the payment methods available, I accept the terms for this booking and the general <termsAndConditionsLink>Terms & Conditions</termsAndConditionsLink>, and understand that Scandic will process my personal data for this booking in accordance with <privacyPolicyLink>Scandic's Privacy policy</privacyPolicyLink>. I also accept that Scandic require a valid credit card during my visit in case anything is left unpaid.": "Mit der Zahlung über eine der verfügbaren Zahlungsmethoden akzeptiere ich die Buchungsbedingungen und die allgemeinen <termsAndConditionsLink>Geschäftsbedingungen</termsAndConditionsLink> und verstehe, dass Scandic meine personenbezogenen Daten im Zusammenhang mit dieser Buchung gemäß der <privacyPolicyLink>Scandic Datenschutzrichtlinie</privacyPolicyLink> verarbeitet. Ich akzeptiere, dass Scandic während meines Aufenthalts eine gültige Kreditkarte für eventuelle Rückerstattungen benötigt.",
|
||||
@@ -365,6 +368,7 @@
|
||||
"Retype new password": "Neues Passwort erneut eingeben",
|
||||
"Room": "Zimmer",
|
||||
"Room & Terms": "Zimmer & Bedingungen",
|
||||
"Room charge": "Zimmerpreis",
|
||||
"Room facilities": "Zimmerausstattung",
|
||||
"Rooms": "Räume",
|
||||
"Rooms & Guests": "Zimmer & Gäste",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"At latest": "At latest",
|
||||
"At the hotel": "At the hotel",
|
||||
"Attractions": "Attractions",
|
||||
"Average price per night": "Average price per night",
|
||||
"Away from elevator": "Away from elevator",
|
||||
"Back to scandichotels.com": "Back to scandichotels.com",
|
||||
"Back to top": "Back to top",
|
||||
@@ -65,12 +66,15 @@
|
||||
"Booking number": "Booking number",
|
||||
"Breakfast": "Breakfast",
|
||||
"Breakfast buffet": "Breakfast buffet",
|
||||
"Breakfast charge": "Breakfast charge",
|
||||
"Breakfast deal can be purchased at the hotel.": "Breakfast deal can be purchased at the hotel.",
|
||||
"Breakfast excluded": "Breakfast excluded",
|
||||
"Breakfast included": "Breakfast included",
|
||||
"Breakfast is included.": "Breakfast is included.",
|
||||
"Breakfast restaurant": "Breakfast restaurant",
|
||||
"Breakfast selection in next step.": "Breakfast selection in next step.",
|
||||
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}": "Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}",
|
||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}": "Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
||||
"Bus terminal": "Bus terminal",
|
||||
"Business": "Business",
|
||||
"By accepting the <termsAndConditionsLink>Terms and Conditions for Scandic Friends</termsAndConditionsLink> I understand that my personal data will be processed in accordance with <privacyPolicy>Scandic's Privacy Policy</privacyPolicy>.": "By accepting the <termsAndConditionsLink>Terms and Conditions for Scandic Friends</termsAndConditionsLink> I understand that my personal data will be processed in accordance with <privacyPolicy>Scandic's Privacy Policy</privacyPolicy>.",
|
||||
@@ -403,6 +407,7 @@
|
||||
"Retype new password": "Retype new password",
|
||||
"Room": "Room",
|
||||
"Room & Terms": "Room & Terms",
|
||||
"Room charge": "Room charge",
|
||||
"Room facilities": "Room facilities",
|
||||
"Rooms": "Rooms",
|
||||
"Rooms & Guests": "Rooms & Guests",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"At latest": "Viimeistään",
|
||||
"At the hotel": "Hotellissa",
|
||||
"Attractions": "Nähtävyydet",
|
||||
"Average price per night": "keskihinta per yö",
|
||||
"Away from elevator": "Kaukana hissistä",
|
||||
"Back to scandichotels.com": "Takaisin scandichotels.com",
|
||||
"Back to top": "Takaisin ylös",
|
||||
@@ -68,6 +69,9 @@
|
||||
"Breakfast is included.": "Aamiainen sisältyy.",
|
||||
"Breakfast restaurant": "Breakfast restaurant",
|
||||
"Breakfast selection in next step.": "Aamiaisvalinta seuraavassa vaiheessa.",
|
||||
"Breakfast charge": "Aamiaismaksu",
|
||||
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}": "Aamiainen ({totalAdults, plural, one {# aikuinen} other {# aikuiset}}) x {totalBreakfasts}",
|
||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}": "Aamiainen ({totalChildren, plural, one {# lapsi} other {# lasta}}) x {totalBreakfasts}",
|
||||
"Bus terminal": "Bussiasema",
|
||||
"Business": "Business",
|
||||
"By accepting the <termsAndConditionsLink>Terms and Conditions for Scandic Friends</termsAndConditionsLink> I understand that my personal data will be processed in accordance with <privacyPolicy>Scandic's Privacy Policy</privacyPolicy>.": "Kyllä, <termsAndConditionsLink>hyväksyn Scandic Friends -jäsenyyttä</termsAndConditionsLink> koskevat ehdot ja ymmärrän, että Scandic käsittelee henkilötietojani <privacyPolicy>Scandicin Tietosuojaselosteen mukaisesti</privacyPolicy>.",
|
||||
@@ -365,6 +369,7 @@
|
||||
"Restaurants & Bars": "Restaurants & Bars",
|
||||
"Retype new password": "Kirjoita uusi salasana uudelleen",
|
||||
"Room & Terms": "Huone & Ehdot",
|
||||
"Room charge": "Huonemaksu",
|
||||
"Room facilities": "Huoneen varustelu",
|
||||
"Rooms": "Huoneet",
|
||||
"Rooms & Guests": "Huoneet & Vieraat",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"At latest": "Senest",
|
||||
"At the hotel": "På hotellet",
|
||||
"Attractions": "Attraksjoner",
|
||||
"Average price per night": "gjennomsnittlig pris per natt",
|
||||
"Away from elevator": "Bort fra heisen",
|
||||
"Back to scandichotels.com": "Tilbake til scandichotels.com",
|
||||
"Back to top": "Tilbake til toppen",
|
||||
@@ -68,6 +69,9 @@
|
||||
"Breakfast is included.": "Frokost er inkludert.",
|
||||
"Breakfast restaurant": "Breakfast restaurant",
|
||||
"Breakfast selection in next step.": "Frokostvalg i neste steg.",
|
||||
"Breakfast charge": "Pris for frokost",
|
||||
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}": "Frokost ({totalAdults, plural, one {# voksen} other {# voksne}}) x {totalBreakfasts}",
|
||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}": "Frokost ({totalChildren, plural, one {# barn} other {# barn}}) x {totalBreakfasts}",
|
||||
"Bus terminal": "Bussterminal",
|
||||
"Business": "Forretnings",
|
||||
"By accepting the <termsAndConditionsLink>Terms and Conditions for Scandic Friends</termsAndConditionsLink> I understand that my personal data will be processed in accordance with <privacyPolicy>Scandic's Privacy Policy</privacyPolicy>.": "Ved å akseptere <termsAndConditionsLink>vilkårene og betingelsene for Scandic Friends</termsAndConditionsLink>, er jeg inneforstått med at mine personopplysninger vil bli behandlet i samsvar med <privacyPolicy>Scandics personvernpolicy</privacyPolicy>.",
|
||||
@@ -364,6 +368,7 @@
|
||||
"Restaurants & Bars": "Restaurants & Bars",
|
||||
"Retype new password": "Skriv inn nytt passord på nytt",
|
||||
"Room & Terms": "Rom & Vilkår",
|
||||
"Room charge": "Pris for rom",
|
||||
"Room facilities": "Romfasiliteter",
|
||||
"Rooms": "Rom",
|
||||
"Rooms & Guests": "Rom og gjester",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"At latest": "Senast",
|
||||
"At the hotel": "På hotellet",
|
||||
"Attractions": "Sevärdheter",
|
||||
"Average price per night": "Snittpris per natt",
|
||||
"Away from elevator": "Bort från hissen",
|
||||
"Back to scandichotels.com": "Tillbaka till scandichotels.com",
|
||||
"Back to top": "Tillbaka till toppen",
|
||||
@@ -68,6 +69,9 @@
|
||||
"Breakfast is included.": "Frukost ingår.",
|
||||
"Breakfast restaurant": "Breakfast restaurant",
|
||||
"Breakfast selection in next step.": "Frukostval i nästa steg.",
|
||||
"Breakfast charge": "Frukostpris",
|
||||
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}": "Frukost ({totalAdults, plural, one {# vuxen} other {# vuxna}}) x {totalBreakfasts}",
|
||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}": "Frukost ({totalChildren, plural, one {# barn} other {# barn}}) x {totalBreakfasts}",
|
||||
"Bus terminal": "Bussterminal",
|
||||
"Business": "Business",
|
||||
"By accepting the <termsAndConditionsLink>Terms and Conditions for Scandic Friends</termsAndConditionsLink> I understand that my personal data will be processed in accordance with <privacyPolicy>Scandic's Privacy Policy</privacyPolicy>.": "Genom att acceptera <termsAndConditionsLink>villkoren för Scandic Friends</termsAndConditionsLink> förstår jag att mina personuppgifter kommer att behandlas i enlighet med <privacyPolicy>Scandics Integritetspolicy</privacyPolicy>.",
|
||||
@@ -364,6 +368,7 @@
|
||||
"Restaurants & Bars": "Restaurants & Bars",
|
||||
"Retype new password": "Upprepa nytt lösenord",
|
||||
"Room & Terms": "Rum & Villkor",
|
||||
"Room charge": "Rumspris",
|
||||
"Room facilities": "Rumfaciliteter",
|
||||
"Rooms": "Rum",
|
||||
"Rooms & Guests": "Rum och gäster",
|
||||
|
||||
Reference in New Issue
Block a user