feat: SW-2028 Fixed review comments

This commit is contained in:
Hrishikesh Vaipurkar
2025-03-31 16:35:52 +02:00
parent 4e9ee82efa
commit 96fd0b73e4
14 changed files with 214 additions and 195 deletions

View File

@@ -5,13 +5,13 @@ import { useFormContext } from "react-hook-form"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { REDEMPTION } from "@/constants/booking"
import Modal from "@/components/Modal"
import Button from "@/components/TempDesignSystem/Button"
import Checkbox from "@/components/TempDesignSystem/Form/Checkbox"
import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption"
import { RemoveExtraRooms } from "../BookingCode"
@@ -97,19 +97,19 @@ export default function RewardNight() {
<MaterialIcon
icon="info"
size={20}
color="Icon/Feedback/Information"
color="Icon/Interactive/Placeholder"
className={styles.errorIcon}
/>
</Button>
}
title={reward}
>
<Body
color="uiTextHighContrast"
<Typography
variant="Body/Paragraph/mdRegular"
className={styles.rewardNightTooltip}
>
{rewardNightTooltip}
</Body>
<span>{rewardNightTooltip}</span>
</Typography>
</Modal>
</div>
</Checkbox>

View File

@@ -138,7 +138,8 @@ export default function PriceDetailsTable({
"corporateCheque" in room.roomRate
? room.roomRate.corporateCheque
: undefined
const redemptionPrice = "redemption" in room.roomRate ? room.roomRate.redemption : undefined
const redemptionPrice =
"redemption" in room.roomRate ? room.roomRate.redemption : undefined
if (!price && !voucherPrice && !chequePrice && !redemptionPrice) {
return null
}
@@ -283,25 +284,18 @@ export default function PriceDetailsTable({
})}
<TableSection>
<TableSectionHeader title={intl.formatMessage({ id: "Total" })} />
{
// @ts-expect-error Currency type is string instead of CurrencyEnum. Change also impacts packages
!noVatCurrencies.includes(totalPrice.local.currency) ? (
<>
<Row
label={intl.formatMessage({ id: "Price excluding VAT" })}
value={formatPrice(
intl,
priceExclVat,
totalPrice.local.currency
)}
/>
<Row
label={intl.formatMessage({ id: "VAT {vat}%" }, { vat })}
value={formatPrice(intl, vatAmount, totalPrice.local.currency)}
/>
</>
) : null
}
{!noVatCurrencies.includes(totalPrice.local.currency) ? (
<>
<Row
label={intl.formatMessage({ id: "Price excluding VAT" })}
value={formatPrice(intl, priceExclVat, totalPrice.local.currency)}
/>
<Row
label={intl.formatMessage({ id: "VAT {vat}%" }, { vat })}
value={formatPrice(intl, vatAmount, totalPrice.local.currency)}
/>
</>
) : null}
<tr className={styles.row}>
<td>
<Body textTransform="bold">

View File

@@ -262,8 +262,7 @@ export default function SummaryUI({
{formatPrice(
intl,
0,
room.roomPrice.perStay.local.additionalPriceCurrency ??
room.roomPrice.perStay.local.currency
room.roomPrice.perStay.local.currency
)}
</Body>
</div>

View File

@@ -73,7 +73,9 @@ function HotelCard({
availability.productType?.member?.rateType === RateTypeEnum.Regular
const price = availability.productType
const userHasEnoughPoints = price?.redemptions?.some((r) => r.hasEnoughPoints)
const hasInsufficientPoints = !price?.redemptions?.some(
(r) => r.hasEnoughPoints
)
const notEnoughPointsLabel = intl.formatMessage({ id: "Not enough points" })
return (
@@ -211,7 +213,7 @@ function HotelCard({
))}
</div>
) : null}
{price?.redemptions?.length && !userHasEnoughPoints ? (
{price?.redemptions?.length && hasInsufficientPoints ? (
<Tooltip
arrow="left"
position="bottom"

View File

@@ -7,6 +7,7 @@ import styles from "./specification.module.css"
import type { SpecificationProps } from "@/types/components/hotelReservation/myStay/receipt"
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
import { CurrencyEnum } from "@/types/enums/currency"
export default async function Specification({
ancillaryPackages,
@@ -19,10 +20,10 @@ export default async function Specification({
(p) => p.type === "Breakfast"
)
const breakfastTotalPriceInMoney = breakfastPackages
.filter((p) => p.currency !== "Points")
.filter((p) => p.currency !== CurrencyEnum.POINTS)
.reduce((acc, curr) => acc + curr.totalPrice, 0)
const breakfastTotalPriceInPoints = breakfastPackages
.filter((p) => p.currency === "Points")
.filter((p) => p.currency === CurrencyEnum.POINTS)
.reduce((acc, curr) => acc + curr.totalPrice, 0)
const breakfastCount = breakfastPackages.reduce(
@@ -138,7 +139,7 @@ export default async function Specification({
<dl className={styles.dl}>
<Typography variant="Body/Supporting text (caption)/smRegular">
<dt>
{ancillary.currency !== "Points"
{ancillary.currency !== CurrencyEnum.POINTS
? intl.formatMessage({ id: "Price including VAT" })
: intl.formatMessage({ id: "Price" })}
</dt>

View File

@@ -6,6 +6,7 @@ import { getIntl } from "@/i18n"
import styles from "./total.module.css"
import type { TotalProps } from "@/types/components/hotelReservation/myStay/receipt"
import { CurrencyEnum } from "@/types/enums/currency"
export default async function Total({ booking, currency }: TotalProps) {
const intl = await getIntl()
@@ -14,7 +15,7 @@ export default async function Total({ booking, currency }: TotalProps) {
const totalPriceInMoneyExclVat = booking.totalPriceExVat
const totalVat = booking.vatAmount
const totalPriceInPoints = booking.ancillaries
.filter((a) => a.currency === "Points")
.filter((a) => a.currency === CurrencyEnum.POINTS)
.reduce((acc, curr) => acc + curr.totalPrice, 0)
const moneyString =

View File

@@ -26,6 +26,8 @@ import Total from "./Total"
import styles from "./receipt.module.css"
import { CurrencyEnum } from "@/types/enums/currency"
export async function Receipt({ refId }: { refId: string }) {
const value = decrypt(refId)
if (!value) {
@@ -52,10 +54,12 @@ export async function Receipt({ refId }: { refId: string }) {
})
const currency =
booking.currencyCode !== "Points"
booking.currencyCode !== CurrencyEnum.POINTS
? booking.currencyCode
: (booking.ancillaries.find((a) => a.currency !== "Points")?.currency ??
booking.packages.find((p) => p.currency !== "Points")?.currency)
: (booking.ancillaries.find((a) => a.currency !== CurrencyEnum.POINTS)
?.currency ??
booking.packages.find((p) => p.currency !== CurrencyEnum.POINTS)
?.currency)
return (
<main className={styles.main}>

View File

@@ -83,7 +83,7 @@ export function calculateTotalPrice(
},
{
local: {
currency: "",
currency: CurrencyEnum.Unknown,
price: 0,
regularPrice: undefined,
},
@@ -103,7 +103,7 @@ export function calculateRedemptionTotalPrice(
additionalPriceCurrency: redemption.localPrice.currency
? redemption.localPrice.currency
: undefined,
currency: "PTS",
currency: CurrencyEnum.POINTS,
price: redemption.localPrice.pointsPerStay,
},
}