'use client'
import { getSingleDecimal } from '@scandic-hotels/common/utils/numberFormatting'
import { Alert } from '../Alert'
import { Divider } from '../Divider'
import { FacilityToIcon } from '../FacilityToIcon'
import ImageGallery, { GalleryImage } from '../ImageGallery'
import SkeletonShimmer from '../SkeletonShimmer'
import { TripAdvisorChip } from '../TripAdvisorChip'
import { Typography } from '../Typography'
import HotelDescription from './HotelDescription'
import styles from './hotelInfoCard.module.css'
import { useIntl } from 'react-intl'
import { AlertTypeEnum } from '@scandic-hotels/common/constants/alert'
import { FacilityEnum } from '@scandic-hotels/common/constants/facilities'
export type HotelInfoCardProps = {
hotel: {
id: string
name: string
url: string | null
ratings?: {
tripAdvisor?: { rating: number }
}
}
description: string
address: {
streetAddress: string
city: string
kilometersToCentre: number
}
galleryImages: GalleryImage[]
alerts: SpecialAlertProps['alert'][]
facilities: {
id: FacilityEnum
name: string
}[]
slot?: React.ReactNode
}
export function HotelInfoCard({
hotel,
galleryImages,
address,
facilities,
alerts,
description,
slot,
}: HotelInfoCardProps) {
const intl = useIntl()
const firstFacilities = facilities.slice(0, 5)
return (
{hotel.ratings?.tripAdvisor && (
)}
{hotel.name}
{intl.formatMessage(
{
id: 'hotelInfoCard.kmToCityCenter',
defaultMessage:
'{address}, {city} ∙ {distanceToCityCenterInKm} km to city center',
},
{
address: address.streetAddress,
city: address.city,
distanceToCityCenterInKm: getSingleDecimal(
address.kilometersToCentre
),
}
)}
{description}
{firstFacilities?.map((facility) => (
))}
{slot}
{slot}
{alerts.map((alert) => (
))}
)
}
type SpecialAlertProps = {
alert: { id: string; type: AlertTypeEnum; heading: string; text: string }
}
function SpecialAlert({ alert }: SpecialAlertProps) {
return (
)
}
export function HotelInfoCardSkeleton() {
return (
{[1, 2, 3, 4, 5]?.map((id) => {
return (
)
})}
)
}