Merged in feat(SW-2083)-missing-booking-codes-scenarios-my-stay (pull request #1680)
Feat(SW-2083) missing booking codes scenarios my stay * feat(SW-2083) Show points instead of reward nights * feat(SW-2083) added support for cheque and voucher for totalPrice Approved-by: Niclas Edenvin
This commit is contained in:
@@ -1,11 +1,73 @@
|
||||
"use client"
|
||||
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import { useMyStayRoomDetailsStore } from "@/stores/my-stay/myStayRoomDetailsStore"
|
||||
import { useMyStayTotalPriceStore } from "@/stores/my-stay/myStayTotalPrice"
|
||||
|
||||
import Price, { type Variant } from "../../Price"
|
||||
import Points from "../../Points"
|
||||
import Price from "../../Price"
|
||||
|
||||
export default function TotalPrice({ variant }: { variant: Variant }) {
|
||||
const { totalPrice } = useMyStayTotalPriceStore()
|
||||
import styles from "./totalPrice.module.css"
|
||||
|
||||
return <Price price={totalPrice} variant={variant} />
|
||||
import type { PriceType } from "@/types/components/hotelReservation/myStay/myStay"
|
||||
|
||||
export type Variant =
|
||||
| "Title/Subtitle/lg"
|
||||
| "Title/Subtitle/md"
|
||||
| "Body/Paragraph/mdBold"
|
||||
|
||||
interface TotalPriceProps {
|
||||
variant: Variant
|
||||
type?: PriceType
|
||||
}
|
||||
|
||||
export default function TotalPrice({
|
||||
variant,
|
||||
type = "money",
|
||||
}: TotalPriceProps) {
|
||||
const totalPrice = useMyStayTotalPriceStore((state) => state.totalPrice)
|
||||
const totalPoints = useMyStayTotalPriceStore((state) => state.totalPoints)
|
||||
const bookedRoom = useMyStayRoomDetailsStore((state) => state.bookedRoom)
|
||||
|
||||
const { vouchers, cheques } = bookedRoom
|
||||
|
||||
const intl = useIntl()
|
||||
if (type === "money") {
|
||||
return <Price price={totalPrice} variant={variant} />
|
||||
}
|
||||
|
||||
if (type === "voucher") {
|
||||
return (
|
||||
<Typography variant={variant}>
|
||||
<p>
|
||||
{intl.formatMessage({ id: "{count} voucher" }, { count: vouchers })}
|
||||
</p>
|
||||
</Typography>
|
||||
)
|
||||
}
|
||||
|
||||
if (type === "cheque") {
|
||||
return (
|
||||
<div className={styles.totalPrice}>
|
||||
<Typography variant={variant}>
|
||||
<p>{cheques} CC + </p>
|
||||
</Typography>
|
||||
<Price price={totalPrice} variant={variant} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (totalPrice && totalPrice > 0 && type === "points") {
|
||||
return (
|
||||
<div className={styles.totalPrice}>
|
||||
<Points points={totalPoints} variant={variant} /> +{" "}
|
||||
<Price price={totalPrice} variant={variant} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return <Points points={totalPoints} variant={variant} />
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
.totalPrice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
Reference in New Issue
Block a user