fix: SW-2642 Fixed corporate chq and voucher rates city search * fix: SW-2642 Fixed corporate chq and voucher rates city search * fix: SW-2642 Fixed no availability alert for all hotels * fix: SW-2642 Combined flags to suitable variable * fix: SW-2642 Fixed map view to show prices Approved-by: Arvid Norlin
240 lines
7.7 KiB
TypeScript
240 lines
7.7 KiB
TypeScript
"use client"
|
|
import { useSession } from "next-auth/react"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { selectRate } from "@/constants/routes/hotelReservation"
|
|
|
|
import { FacilityToIcon } from "@/components/ContentType/HotelPage/data"
|
|
import Button from "@/components/TempDesignSystem/Button"
|
|
import Link from "@/components/TempDesignSystem/Link"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
|
import Footnote from "@/components/TempDesignSystem/Text/Footnote"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
import { isValidClientSession } from "@/utils/clientSession"
|
|
|
|
import HotelPointsRow from "../../HotelCard/HotelPointsRow"
|
|
import NoPriceAvailableCard from "../../HotelCard/NoPriceAvailableCard"
|
|
import HotelCardDialogImage from "../HotelCardDialogImage"
|
|
|
|
import styles from "../hotelCardDialog.module.css"
|
|
|
|
import type { HotelPin } from "@/types/components/hotelReservation/selectHotel/map"
|
|
import type { Lang } from "@/constants/languages"
|
|
|
|
interface StandaloneHotelCardProps {
|
|
data: HotelPin
|
|
lang: Lang
|
|
imageError: boolean
|
|
setImageError: (error: boolean) => void
|
|
}
|
|
|
|
export default function StandaloneHotelCardDialog({
|
|
data,
|
|
lang,
|
|
imageError,
|
|
setImageError,
|
|
}: StandaloneHotelCardProps) {
|
|
const intl = useIntl()
|
|
const { data: session } = useSession()
|
|
const isUserLoggedIn = isValidClientSession(session)
|
|
const {
|
|
name,
|
|
chequePrice,
|
|
publicPrice,
|
|
memberPrice,
|
|
redemptionPrice,
|
|
voucherPrice,
|
|
currency,
|
|
amenities,
|
|
images,
|
|
ratings,
|
|
operaId,
|
|
} = data
|
|
|
|
const firstImage = images[0]?.imageSizes?.small
|
|
const altText = images[0]?.metaData?.altText
|
|
|
|
return (
|
|
<>
|
|
<HotelCardDialogImage
|
|
firstImage={firstImage}
|
|
altText={altText}
|
|
ratings={ratings || 0}
|
|
imageError={imageError}
|
|
setImageError={setImageError}
|
|
position="left"
|
|
/>
|
|
<div className={styles.content}>
|
|
<div className={styles.header}>
|
|
<div className={styles.name}>
|
|
<Body textTransform="bold">{name}</Body>
|
|
</div>
|
|
</div>
|
|
<div className={styles.facilities}>
|
|
{amenities.slice(0, 3).map((facility) => {
|
|
const Icon = (
|
|
<FacilityToIcon id={facility.id} size={16} color="Icon/Default" />
|
|
)
|
|
return (
|
|
<div className={styles.facilitiesItem} key={facility.id}>
|
|
{Icon && Icon}
|
|
<Footnote color="uiTextMediumContrast">
|
|
{facility.name}
|
|
</Footnote>
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
<div className={styles.pricesContainer}>
|
|
{publicPrice ||
|
|
memberPrice ||
|
|
redemptionPrice ||
|
|
voucherPrice ||
|
|
chequePrice ? (
|
|
<>
|
|
<div className={styles.priceCard}>
|
|
{redemptionPrice ? (
|
|
<Caption>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Available rates",
|
|
})}
|
|
</Caption>
|
|
) : (
|
|
<Caption type="bold">
|
|
{intl.formatMessage({
|
|
defaultMessage: "From",
|
|
})}
|
|
</Caption>
|
|
)}
|
|
{chequePrice && (
|
|
<Subtitle type="two">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{price} {currency}",
|
|
},
|
|
{
|
|
price: chequePrice.numberOfCheques,
|
|
currency: "CC",
|
|
}
|
|
)}
|
|
{chequePrice.additionalPricePerStay > 0
|
|
? // eslint-disable-next-line formatjs/no-literal-string-in-jsx
|
|
" + " +
|
|
intl.formatMessage(
|
|
{
|
|
defaultMessage: "{price} {currency}",
|
|
},
|
|
{
|
|
price: chequePrice.additionalPricePerStay,
|
|
currency: chequePrice.currency,
|
|
}
|
|
)
|
|
: null}
|
|
<Body asChild>
|
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
|
<span>
|
|
/
|
|
{intl.formatMessage({
|
|
defaultMessage: "night",
|
|
})}
|
|
</span>
|
|
</Body>
|
|
</Subtitle>
|
|
)}
|
|
{voucherPrice && (
|
|
<Subtitle type="two">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{price} {currency}",
|
|
},
|
|
{
|
|
price: voucherPrice,
|
|
currency,
|
|
}
|
|
)}
|
|
<Body asChild>
|
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
|
<span>
|
|
/
|
|
{intl.formatMessage({
|
|
defaultMessage: "night",
|
|
})}
|
|
</span>
|
|
</Body>
|
|
</Subtitle>
|
|
)}
|
|
{publicPrice && !isUserLoggedIn && (
|
|
<Subtitle type="two">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{price} {currency}",
|
|
},
|
|
{
|
|
price: publicPrice,
|
|
currency,
|
|
}
|
|
)}
|
|
<Body asChild>
|
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
|
<span>
|
|
/
|
|
{intl.formatMessage({
|
|
defaultMessage: "night",
|
|
})}
|
|
</span>
|
|
</Body>
|
|
</Subtitle>
|
|
)}
|
|
{memberPrice && (
|
|
<Subtitle type="two" color="red">
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{price} {currency}",
|
|
},
|
|
{
|
|
price: memberPrice,
|
|
currency,
|
|
}
|
|
)}
|
|
<Body asChild color="red">
|
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
|
<span>
|
|
/
|
|
{intl.formatMessage({
|
|
defaultMessage: "night",
|
|
})}
|
|
</span>
|
|
</Body>
|
|
</Subtitle>
|
|
)}
|
|
{redemptionPrice && (
|
|
<HotelPointsRow pointsPerStay={redemptionPrice} />
|
|
)}
|
|
</div>
|
|
<Button
|
|
asChild
|
|
theme="base"
|
|
size="small"
|
|
className={styles.button}
|
|
>
|
|
<Link
|
|
href={`${selectRate(lang)}?hotel=${operaId}`}
|
|
color="none"
|
|
keepSearchParams
|
|
>
|
|
{intl.formatMessage({
|
|
defaultMessage: "See rooms",
|
|
})}
|
|
</Link>
|
|
</Button>
|
|
</>
|
|
) : (
|
|
<NoPriceAvailableCard />
|
|
)}
|
|
</div>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|