227 lines
7.3 KiB
TypeScript
227 lines
7.3 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
|
|
|
import { CancellationRuleEnum } from "@/constants/booking"
|
|
import { dt } from "@/lib/dt"
|
|
|
|
import Image from "@/components/Image"
|
|
import Link from "@/components/TempDesignSystem/Link"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
import useLang from "@/hooks/useLang"
|
|
|
|
import styles from "./room.module.css"
|
|
|
|
import type { RoomProps } from "@/types/components/hotelReservation/bookingConfirmation/rooms/room"
|
|
|
|
export default function Room({
|
|
checkInDate,
|
|
checkOutDate,
|
|
checkInTime,
|
|
checkOutTime,
|
|
confirmationNumber,
|
|
guaranteeInfo,
|
|
guest,
|
|
img,
|
|
rateDefinition,
|
|
roomName,
|
|
}: RoomProps) {
|
|
const intl = useIntl()
|
|
const lang = useLang()
|
|
|
|
const guestName = `${guest.firstName} ${guest.lastName}`
|
|
const fromDate = dt(checkInDate).locale(lang)
|
|
const toDate = dt(checkOutDate).locale(lang)
|
|
const isFlexBooking =
|
|
rateDefinition.cancellationRule ===
|
|
CancellationRuleEnum.CancellableBefore6PM
|
|
const isChangeBooking =
|
|
rateDefinition.cancellationRule === CancellationRuleEnum.Changeable
|
|
return (
|
|
<article className={styles.room}>
|
|
<header className={styles.header}>
|
|
<Typography variant="Title/Subtitle/md">
|
|
<h2>
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "Booking number {value}",
|
|
},
|
|
{ value: confirmationNumber }
|
|
)}
|
|
</h2>
|
|
</Typography>
|
|
{rateDefinition.isMemberRate ? (
|
|
<div className={styles.benefits}>
|
|
<>
|
|
<MaterialIcon
|
|
color="Icon/Feedback/Success"
|
|
icon="check_circle"
|
|
size={20}
|
|
/>
|
|
<Caption>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Membership benefits applied",
|
|
})}
|
|
</Caption>
|
|
</>
|
|
</div>
|
|
) : null}
|
|
{guaranteeInfo && (
|
|
<div className={styles.benefits}>
|
|
<MaterialIcon
|
|
icon="check_circle"
|
|
color="Icon/Feedback/Success"
|
|
size={20}
|
|
/>
|
|
<Typography
|
|
variant="Body/Supporting text (caption)/smBold"
|
|
className={styles.guaranteeText}
|
|
>
|
|
<p>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Booking guaranteed.",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
{/* eslint-disable formatjs/no-literal-string-in-jsx */}{" "}
|
|
{/* eslint-enable formatjs/no-literal-string-in-jsx */}
|
|
<Typography variant="Body/Supporting text (caption)/smRegular">
|
|
<p>
|
|
{intl.formatMessage({
|
|
defaultMessage:
|
|
"Your room will remain available for check-in even after 18:00.",
|
|
})}
|
|
</p>
|
|
</Typography>
|
|
</div>
|
|
)}
|
|
</header>
|
|
<div className={styles.booking}>
|
|
<Image
|
|
alt={img.metaData.altText}
|
|
className={styles.img}
|
|
focalPoint={{ x: 50, y: 50 }}
|
|
height={204}
|
|
src={img.imageSizes.medium}
|
|
style={{ borderRadius: "var(--Corner-radius-Medium)" }}
|
|
title={img.metaData.title}
|
|
width={204}
|
|
/>
|
|
<div className={styles.roomDetails}>
|
|
<div className={styles.roomName}>
|
|
<Subtitle color="uiTextHighContrast" type="two">
|
|
{roomName}
|
|
</Subtitle>
|
|
<Link color="burgundy" href="" variant="icon">
|
|
{intl.formatMessage({
|
|
defaultMessage: "View room details",
|
|
})}
|
|
<MaterialIcon
|
|
icon="chevron_right"
|
|
size={20}
|
|
color="CurrentColor"
|
|
/>
|
|
</Link>
|
|
</div>
|
|
<ul className={styles.details}>
|
|
<li className={styles.listItem}>
|
|
<Body color="uiTextPlaceholder">
|
|
{intl.formatMessage({
|
|
defaultMessage: "Check-in",
|
|
})}
|
|
</Body>
|
|
<Body color="uiTextHighContrast">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{checkInDate} from {checkInTime}",
|
|
},
|
|
{
|
|
checkInDate: fromDate.format("ddd, D MMM"),
|
|
checkInTime: checkInTime,
|
|
}
|
|
)}
|
|
</Body>
|
|
</li>
|
|
<li className={styles.listItem}>
|
|
<Body color="uiTextPlaceholder">
|
|
{intl.formatMessage({
|
|
defaultMessage: "Check-out",
|
|
})}
|
|
</Body>
|
|
<Body color="uiTextHighContrast">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{checkOutDate} from {checkOutTime}",
|
|
},
|
|
{
|
|
checkOutDate: toDate.format("ddd, D MMM"),
|
|
checkOutTime: checkOutTime,
|
|
}
|
|
)}
|
|
</Body>
|
|
</li>
|
|
<li className={styles.listItem}>
|
|
<Body color="uiTextPlaceholder">
|
|
{intl.formatMessage({
|
|
defaultMessage: "Cancellation policy",
|
|
})}
|
|
</Body>
|
|
<Body color="uiTextHighContrast">
|
|
{rateDefinition.cancellationText}
|
|
</Body>
|
|
</li>
|
|
{isFlexBooking || isChangeBooking ? (
|
|
<li className={styles.listItem}>
|
|
<Body color="uiTextPlaceholder">
|
|
{intl.formatMessage({
|
|
defaultMessage: "Change or cancel",
|
|
})}
|
|
</Body>
|
|
<Body color="uiTextHighContrast">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "Until {time}, {date}",
|
|
},
|
|
{ time: "18:00", date: fromDate.format("dddd D MMM") }
|
|
)}
|
|
</Body>
|
|
</li>
|
|
) : null}
|
|
</ul>
|
|
<div className={styles.guest}>
|
|
<Body color="uiTextPlaceholder">
|
|
{intl.formatMessage({
|
|
defaultMessage: "Main guest",
|
|
})}
|
|
</Body>
|
|
<Body color="uiTextHighContrast">{guestName}</Body>
|
|
{guest.membershipNumber ? (
|
|
<Body color="uiTextHighContrast">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "Friend no. {value}",
|
|
},
|
|
{
|
|
value: guest.membershipNumber,
|
|
}
|
|
)}
|
|
</Body>
|
|
) : null}
|
|
{guest.phoneNumber ? (
|
|
<Body color="uiTextHighContrast">{guest.phoneNumber}</Body>
|
|
) : null}
|
|
{guest.email ? (
|
|
<Body color="uiTextHighContrast">{guest.email}</Body>
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
)
|
|
}
|