feat(SW-176): destructure response
This commit is contained in:
@@ -29,14 +29,16 @@ export default async function HotelCard({
|
||||
}: HotelCardProps) {
|
||||
const intl = await getIntl()
|
||||
|
||||
const hotelData = await serverClient().hotel.get({
|
||||
const hotelResponse = await serverClient().hotel.get({
|
||||
hotelId: hotelId.toString(),
|
||||
language: getLang(),
|
||||
})
|
||||
|
||||
if (!hotelData) return null
|
||||
if (!hotelResponse) return null
|
||||
|
||||
const sortedAmenities = hotelData.hotel.detailedFacilities
|
||||
const { hotel } = hotelResponse
|
||||
|
||||
const sortedAmenities = hotel.detailedFacilities
|
||||
.sort((a, b) => b.sortOrder - a.sortOrder)
|
||||
.slice(0, 5)
|
||||
|
||||
@@ -44,8 +46,8 @@ export default async function HotelCard({
|
||||
<article className={styles.card}>
|
||||
<section className={styles.imageContainer}>
|
||||
<Image
|
||||
src={hotelData.hotel.hotelContent.images.imageSizes.large}
|
||||
alt={hotelData.hotel.hotelContent.images.metaData.altText}
|
||||
src={hotel.hotelContent.images.imageSizes.large}
|
||||
alt={hotel.hotelContent.images.metaData.altText}
|
||||
width={300}
|
||||
height={200}
|
||||
className={styles.image}
|
||||
@@ -53,20 +55,20 @@ export default async function HotelCard({
|
||||
<div className={styles.tripAdvisor}>
|
||||
<Chip intent="primary" className={styles.tripAdvisor}>
|
||||
<TripAdvisorIcon color="white" />
|
||||
{hotelData.hotel.ratings?.tripAdvisor.rating}
|
||||
{hotel.ratings?.tripAdvisor.rating}
|
||||
</Chip>
|
||||
</div>
|
||||
</section>
|
||||
<section className={styles.hotelInformation}>
|
||||
<ScandicLogoIcon color="red" />
|
||||
<Title as="h4" textTransform="capitalize">
|
||||
{hotelData.hotel.name}
|
||||
{hotel.name}
|
||||
</Title>
|
||||
<Footnote color="textMediumContrast" className={styles.adress}>
|
||||
{`${hotelData.hotel.address.streetAddress}, ${hotelData.hotel.address.city}`}
|
||||
{`${hotel.address.streetAddress}, ${hotel.address.city}`}
|
||||
</Footnote>
|
||||
<Footnote color="textMediumContrast">
|
||||
{`${hotelData.hotel.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`}
|
||||
{`${hotel.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`}
|
||||
</Footnote>
|
||||
</section>
|
||||
<section className={styles.hotel}>
|
||||
|
||||
Reference in New Issue
Block a user