feat(SW-176): destructure response
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
import tempHotelData from "@/server/routers/hotels/tempHotelData.json"
|
import tempHotelData from "@/server/routers/hotels/tempHotelData.json"
|
||||||
|
|
||||||
import HotelCard from "@/components/HotelReservation/HotelCard"
|
|
||||||
import BedSelection from "@/components/HotelReservation/SelectRate/BedSelection"
|
import BedSelection from "@/components/HotelReservation/SelectRate/BedSelection"
|
||||||
import BreakfastSelection from "@/components/HotelReservation/SelectRate/BreakfastSelection"
|
import BreakfastSelection from "@/components/HotelReservation/SelectRate/BreakfastSelection"
|
||||||
import Details from "@/components/HotelReservation/SelectRate/Details"
|
import Details from "@/components/HotelReservation/SelectRate/Details"
|
||||||
@@ -108,7 +107,7 @@ export default async function SectionsPage({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<HotelCard hotel={hotel} />
|
<div>Hotel Card TBI</div>
|
||||||
|
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<div className={styles.main}>
|
<div className={styles.main}>
|
||||||
|
|||||||
@@ -20,19 +20,22 @@ export default async function SelectHotelPage({
|
|||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
|
|
||||||
const tempSearchTerm = "Stockholm"
|
const tempSearchTerm = "Stockholm"
|
||||||
|
|
||||||
const hotelFilters = await serverClient().hotel.filters.get({
|
const hotelFilters = await serverClient().hotel.filters.get({
|
||||||
hotelId: "879",
|
hotelId: "879",
|
||||||
})
|
})
|
||||||
|
|
||||||
const availability = await serverClient().hotel.availability.get({
|
const availabilityResponse = await serverClient().hotel.availability.get({
|
||||||
cityId: "8ec4bba3-1c38-4606-82d1-bbe3f6738e54",
|
cityId: "8ec4bba3-1c38-4606-82d1-bbe3f6738e54",
|
||||||
roomStayStartDate: "2024-11-02",
|
roomStayStartDate: "2024-11-02",
|
||||||
roomStayEndDate: "2024-11-03",
|
roomStayEndDate: "2024-11-03",
|
||||||
adults: 1,
|
adults: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
const filterAvailability = availability?.availability.data
|
if (!availabilityResponse) return null
|
||||||
|
|
||||||
|
const { availability } = availabilityResponse
|
||||||
|
|
||||||
|
const filterAvailability = availability.data
|
||||||
.filter((hotels) => hotels.attributes.status === "Available")
|
.filter((hotels) => hotels.attributes.status === "Available")
|
||||||
.flatMap((hotels) => hotels.attributes)
|
.flatMap((hotels) => hotels.attributes)
|
||||||
|
|
||||||
@@ -53,7 +56,7 @@ export default async function SelectHotelPage({
|
|||||||
<HotelFilter filters={hotelFilters} />
|
<HotelFilter filters={hotelFilters} />
|
||||||
</section>
|
</section>
|
||||||
<section className={styles.hotelCards}>
|
<section className={styles.hotelCards}>
|
||||||
{filterAvailability?.length ? (
|
{filterAvailability.length ? (
|
||||||
filterAvailability.map((hotel) => (
|
filterAvailability.map((hotel) => (
|
||||||
<HotelCard
|
<HotelCard
|
||||||
key={hotel.hotelId}
|
key={hotel.hotelId}
|
||||||
|
|||||||
@@ -29,14 +29,16 @@ export default async function HotelCard({
|
|||||||
}: HotelCardProps) {
|
}: HotelCardProps) {
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
const hotelData = await serverClient().hotel.get({
|
const hotelResponse = await serverClient().hotel.get({
|
||||||
hotelId: hotelId.toString(),
|
hotelId: hotelId.toString(),
|
||||||
language: getLang(),
|
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)
|
.sort((a, b) => b.sortOrder - a.sortOrder)
|
||||||
.slice(0, 5)
|
.slice(0, 5)
|
||||||
|
|
||||||
@@ -44,8 +46,8 @@ export default async function HotelCard({
|
|||||||
<article className={styles.card}>
|
<article className={styles.card}>
|
||||||
<section className={styles.imageContainer}>
|
<section className={styles.imageContainer}>
|
||||||
<Image
|
<Image
|
||||||
src={hotelData.hotel.hotelContent.images.imageSizes.large}
|
src={hotel.hotelContent.images.imageSizes.large}
|
||||||
alt={hotelData.hotel.hotelContent.images.metaData.altText}
|
alt={hotel.hotelContent.images.metaData.altText}
|
||||||
width={300}
|
width={300}
|
||||||
height={200}
|
height={200}
|
||||||
className={styles.image}
|
className={styles.image}
|
||||||
@@ -53,20 +55,20 @@ export default async function HotelCard({
|
|||||||
<div className={styles.tripAdvisor}>
|
<div className={styles.tripAdvisor}>
|
||||||
<Chip intent="primary" className={styles.tripAdvisor}>
|
<Chip intent="primary" className={styles.tripAdvisor}>
|
||||||
<TripAdvisorIcon color="white" />
|
<TripAdvisorIcon color="white" />
|
||||||
{hotelData.hotel.ratings?.tripAdvisor.rating}
|
{hotel.ratings?.tripAdvisor.rating}
|
||||||
</Chip>
|
</Chip>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section className={styles.hotelInformation}>
|
<section className={styles.hotelInformation}>
|
||||||
<ScandicLogoIcon color="red" />
|
<ScandicLogoIcon color="red" />
|
||||||
<Title as="h4" textTransform="capitalize">
|
<Title as="h4" textTransform="capitalize">
|
||||||
{hotelData.hotel.name}
|
{hotel.name}
|
||||||
</Title>
|
</Title>
|
||||||
<Footnote color="textMediumContrast" className={styles.adress}>
|
<Footnote color="textMediumContrast" className={styles.adress}>
|
||||||
{`${hotelData.hotel.address.streetAddress}, ${hotelData.hotel.address.city}`}
|
{`${hotel.address.streetAddress}, ${hotel.address.city}`}
|
||||||
</Footnote>
|
</Footnote>
|
||||||
<Footnote color="textMediumContrast">
|
<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>
|
</Footnote>
|
||||||
</section>
|
</section>
|
||||||
<section className={styles.hotel}>
|
<section className={styles.hotel}>
|
||||||
|
|||||||
Reference in New Issue
Block a user