"use client" import { Link } from "react-aria-components" import { useIntl } from "react-intl" import { dt } from "@scandic-hotels/common/dt" import { Divider } from "@scandic-hotels/design-system/Divider" import Image from "@scandic-hotels/design-system/Image" import ImageFallback from "@scandic-hotels/design-system/ImageFallback" import { Typography } from "@scandic-hotels/design-system/Typography" import useLang from "@/hooks/useLang" import { getTimeAgoText } from "@/utils/getTimeAgoText" import styles from "./stayCard.module.css" import type { StayCardProps } from "@/types/components/myPages/stays/stayCard" export function StayCard({ stay, ref }: StayCardProps) { const { bookingUrl, isWebAppOrigin: shouldLinkToMyStay } = stay.attributes if (!shouldLinkToMyStay) { return } return ( ) } function CardContent({ stay }: { stay: StayCardProps["stay"] }) { const lang = useLang() const intl = useIntl() const { checkinDate, checkoutDate, hotelInformation } = stay.attributes const arrival = dt(checkinDate).locale(lang) const arrivalDate = arrival.format("DD MMM") const arrivalDateTime = arrival.format("YYYY-MM-DD") const depart = dt(checkoutDate).locale(lang) const departDate = depart.format("DD MMM YYYY") const departDateTime = depart.format("YYYY-MM-DD") const timeAgoText = getTimeAgoText(checkoutDate, intl) return (
{hotelInformation.hotelContent.images.src ? ( { ) : ( )}

{hotelInformation.hotelName}

{hotelInformation.cityName && (

{hotelInformation.cityName}

)}
{timeAgoText ? (
{timeAgoText}
) : null}
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
) }