Merged in feat(SW-1722)-mystay-multiroom-view (pull request #1396)

Feat(SW-1722) mystay multiroom view

* feat(SW-1722) View all rooms on my stay

* feat(sW-1722) Show linked reservation

* feat(SW-1722) merged monorepo

* feat(SW-1722) yarn install

* feat(SW-1722) removed unused data

* feat(SW-1722) Streaming data from the server to the client


Approved-by: Niclas Edenvin
This commit is contained in:
Pontus Dreij
2025-02-27 07:24:56 +00:00
parent 0c498d82ca
commit 31a536b1f7
11 changed files with 364 additions and 39 deletions

View File

@@ -17,22 +17,23 @@ import useLang from "@/hooks/useLang"
import { formatPrice } from "@/utils/numberFormatting"
import ManageStay from "../ManageStay"
import { useMyStayTotalPriceStore } from "../stores/myStayTotalPrice"
import styles from "./referenceCard.module.css"
import type { Hotel } from "@/types/hotel"
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
export function ReferenceCard({
booking,
hotel,
}: {
interface ReferenceCardProps {
booking: BookingConfirmation["booking"]
hotel: Hotel
}) {
}
export function ReferenceCard({ booking, hotel }: ReferenceCardProps) {
const [bookingStatus, setBookingStatus] = useState(booking.reservationStatus)
const intl = useIntl()
const lang = useLang()
const { totalPrice, currencyCode } = useMyStayTotalPriceStore()
const fromDate = dt(booking.checkInDate).locale(lang)
const toDate = dt(booking.checkOutDate).locale(lang)
@@ -43,6 +44,19 @@ export function ReferenceCard({
const directionsUrl = `https://www.google.com/maps/dir/?api=1&destination=${hotel.location.latitude},${hotel.location.longitude}`
const adults =
booking.adults +
(booking.linkedReservations?.reduce(
(acc, linkedReservation) => acc + linkedReservation.adults,
0
) ?? 0)
const children =
booking.childrenAges.length +
(booking.linkedReservations?.reduce(
(acc, linkedReservation) => acc + linkedReservation.children,
0
) ?? 0)
return (
<div className={styles.referenceCard}>
<div className={styles.referenceRow}>
@@ -56,9 +70,7 @@ export function ReferenceCard({
</Subtitle>
<Subtitle color="uiTextHighContrast">
{/* TODO: Implement this: https://scandichotels.atlassian.net/browse/API2-2883 to get correct cancellation number */}
{isCancelled
? booking.linkedReservations[0]?.cancellationNumber
: booking.confirmationNumber}
{isCancelled ? "" : booking.confirmationNumber}
</Subtitle>
</div>
<Divider color="primaryLightSubtle" className={styles.divider} />
@@ -75,14 +87,14 @@ export function ReferenceCard({
? intl.formatMessage(
{ id: "{adults} adults, {children} children" },
{
adults: booking.adults,
children: booking.childrenAges.length,
adults: adults,
children: children,
}
)
: intl.formatMessage(
{ id: "{adults} adults" },
{
adults: booking.adults,
adults: adults,
}
)}
</Caption>
@@ -121,7 +133,7 @@ export function ReferenceCard({
{intl.formatMessage({ id: "Total paid" })}
</Caption>
<Caption type="bold" color="uiTextHighContrast">
{formatPrice(intl, booking.totalPrice, booking.currencyCode)}
{formatPrice(intl, totalPrice, currencyCode)}
</Caption>
</div>
{!showCancelButton && (
@@ -150,7 +162,7 @@ export function ReferenceCard({
</Link>
</Button>
</div>
{booking.rateDefinition.cancellationRule !== "NotCancellable" && (
{booking.isModifiable && (
<Caption className={styles.note} color="uiTextHighContrast">
{intl.formatMessage(
{