feat/SW-763-image-gallery-update (pull request #846)
feat(SW-763): update to smallerImages for select-hotel/rate page and slice size depending on signature * feat(SW-763): update to smallerImages for select- hotel/rate page and slice size depending on signature * fix(SW-763): add hotelType enum * feat(SW-763): move hotel type check to the route for the hotelData * fix(SW-763): remove unused import * fix(SW-763): fix comment * fix(SW-763): add optional galleryImages check Approved-by: Christian Andolf Approved-by: Pontus Dreij Approved-by: Niclas Edenvin
This commit is contained in:
@@ -56,13 +56,10 @@ export default function HotelCard({
|
|||||||
onMouseLeave={handleMouseLeave}
|
onMouseLeave={handleMouseLeave}
|
||||||
>
|
>
|
||||||
<section className={styles.imageContainer}>
|
<section className={styles.imageContainer}>
|
||||||
{hotelData.gallery && (
|
{hotelData?.galleryImages && (
|
||||||
<ImageGallery
|
<ImageGallery
|
||||||
title={hotelData.name}
|
title={hotelData.name}
|
||||||
images={[
|
images={hotelData.galleryImages}
|
||||||
hotelData.hotelContent.images,
|
|
||||||
...hotelData.gallery.heroImages,
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className={styles.tripAdvisor}>
|
<div className={styles.tripAdvisor}>
|
||||||
|
|||||||
@@ -29,13 +29,10 @@ export default function HotelInfoCard({ hotelData }: HotelInfoCardProps) {
|
|||||||
{hotelAttributes && (
|
{hotelAttributes && (
|
||||||
<section className={styles.wrapper}>
|
<section className={styles.wrapper}>
|
||||||
<div className={styles.imageWrapper}>
|
<div className={styles.imageWrapper}>
|
||||||
{hotelAttributes.gallery && (
|
{hotelAttributes?.galleryImages && (
|
||||||
<ImageGallery
|
<ImageGallery
|
||||||
title={hotelAttributes.name}
|
title={hotelAttributes.name}
|
||||||
images={[
|
images={hotelAttributes.galleryImages}
|
||||||
hotelAttributes.hotelContent.images,
|
|
||||||
...hotelAttributes.gallery.heroImages,
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{hotelAttributes.ratings?.tripAdvisor && (
|
{hotelAttributes.ratings?.tripAdvisor && (
|
||||||
|
|||||||
@@ -449,6 +449,7 @@ export const getHotelDataSchema = z.object({
|
|||||||
facilities.sort((a, b) => b.sortOrder - a.sortOrder)
|
facilities.sort((a, b) => b.sortOrder - a.sortOrder)
|
||||||
),
|
),
|
||||||
gallery: gallerySchema.optional(),
|
gallery: gallerySchema.optional(),
|
||||||
|
galleryImages: z.array(imageSchema).optional(),
|
||||||
healthAndWellness: facilitySchema.optional(),
|
healthAndWellness: facilitySchema.optional(),
|
||||||
healthFacilities: z.array(healthFacilitySchema),
|
healthFacilities: z.array(healthFacilitySchema),
|
||||||
hotelContent: hotelContentSchema,
|
hotelContent: hotelContentSchema,
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import { FacilityCardTypeEnum } from "@/types/components/hotelPage/facilities"
|
|||||||
import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType"
|
import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType"
|
||||||
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
||||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||||
|
import { HotelTypeEnum } from "@/types/enums/hotelType"
|
||||||
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
||||||
import type { Facility } from "@/types/hotel"
|
import type { Facility } from "@/types/hotel"
|
||||||
import type { GetHotelPageData } from "@/types/trpc/routers/contentstack/hotelPage"
|
import type { GetHotelPageData } from "@/types/trpc/routers/contentstack/hotelPage"
|
||||||
@@ -257,13 +258,22 @@ export const getHotelData = cache(
|
|||||||
query: { hotelId, params: params },
|
query: { hotelId, params: params },
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
const hotelData = validateHotelData.data
|
||||||
|
|
||||||
if (isCardOnlyPayment) {
|
if (isCardOnlyPayment) {
|
||||||
validateHotelData.data.data.attributes.merchantInformationData.alternatePaymentOptions =
|
hotelData.data.attributes.merchantInformationData.alternatePaymentOptions =
|
||||||
[]
|
[]
|
||||||
}
|
}
|
||||||
|
if (hotelData.data.attributes.gallery) {
|
||||||
|
const smallerImages = hotelData.data.attributes.gallery.smallerImages
|
||||||
|
const hotelGalleryImages =
|
||||||
|
hotelData.data.attributes.hotelType === HotelTypeEnum.Signature
|
||||||
|
? smallerImages.slice(0, 10)
|
||||||
|
: smallerImages.slice(0, 6)
|
||||||
|
hotelData.data.attributes.galleryImages = hotelGalleryImages
|
||||||
|
}
|
||||||
|
|
||||||
return validateHotelData.data
|
return hotelData
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
5
types/enums/hotelType.ts
Normal file
5
types/enums/hotelType.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export enum HotelTypeEnum {
|
||||||
|
Signature = "signature",
|
||||||
|
ScandicGo = "scandicgo",
|
||||||
|
Regular = "regular",
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user