fix(SW-712): remove hotelFacts.hotelFacilityDetail, hotelFacts.hotelInformation and use detailedFacilities
This commit is contained in:
@@ -16,22 +16,17 @@ import Contact from "../Contact"
|
||||
import styles from "./readMore.module.css"
|
||||
|
||||
import {
|
||||
DetailedAmenity,
|
||||
ParkingProps,
|
||||
ReadMoreProps,
|
||||
} from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
||||
import { Hotel } from "@/types/hotel"
|
||||
import type { Amenities,Hotel } from "@/types/hotel"
|
||||
|
||||
function getAmenitiesList(hotel: Hotel) {
|
||||
const detailedAmenities: DetailedAmenity[] = Object.entries(
|
||||
hotel.hotelFacts.hotelFacilityDetail
|
||||
).map(([key, value]) => ({ name: key, ...value }))
|
||||
|
||||
// Remove Parking facilities since parking accordion is based on hotel.parking
|
||||
const simpleAmenities = hotel.detailedFacilities.filter(
|
||||
(facility) => !facility.name.startsWith("Parking")
|
||||
const detailedAmenities: Amenities = hotel.detailedFacilities.filter(
|
||||
// Remove Parking facilities since parking accordion is based on hotel.parking
|
||||
(facility) => !facility.name.startsWith("Parking") && facility.public
|
||||
)
|
||||
return [...detailedAmenities, ...simpleAmenities]
|
||||
return detailedAmenities
|
||||
}
|
||||
|
||||
export default function ReadMore({ label, hotel, hotelId }: ReadMoreProps) {
|
||||
@@ -80,11 +75,7 @@ export default function ReadMore({ label, hotel, hotelId }: ReadMoreProps) {
|
||||
TODO: What content should be in the accessibility section?
|
||||
</AccordionItem>
|
||||
{amenitiesList.map((amenity) => {
|
||||
return "description" in amenity ? (
|
||||
<AccordionItem key={amenity.name} title={amenity.heading}>
|
||||
{amenity.description}
|
||||
</AccordionItem>
|
||||
) : (
|
||||
return (
|
||||
<div key={amenity.id} className={styles.amenity}>
|
||||
{amenity.name}
|
||||
</div>
|
||||
|
||||
@@ -71,34 +71,6 @@ const ecoLabelsSchema = z.object({
|
||||
svanenEcoLabelCertificateNumber: z.string().optional(),
|
||||
})
|
||||
|
||||
const hotelFacilityDetailSchema = z.object({
|
||||
heading: z.string(),
|
||||
description: z.string(),
|
||||
})
|
||||
|
||||
const hotelFacilitySchema = z.object({
|
||||
breakfast: hotelFacilityDetailSchema,
|
||||
checkout: hotelFacilityDetailSchema,
|
||||
gym: hotelFacilityDetailSchema,
|
||||
internet: hotelFacilityDetailSchema,
|
||||
laundry: hotelFacilityDetailSchema,
|
||||
luggage: hotelFacilityDetailSchema,
|
||||
shop: hotelFacilityDetailSchema,
|
||||
telephone: hotelFacilityDetailSchema,
|
||||
})
|
||||
|
||||
const hotelInformationDetailSchema = z.object({
|
||||
heading: z.string(),
|
||||
description: z.string(),
|
||||
link: z.string().optional(),
|
||||
})
|
||||
|
||||
const hotelInformationSchema = z.object({
|
||||
accessibility: hotelInformationDetailSchema,
|
||||
safety: hotelInformationDetailSchema,
|
||||
sustainability: hotelInformationDetailSchema,
|
||||
})
|
||||
|
||||
const interiorSchema = z.object({
|
||||
numberOfBeds: z.number(),
|
||||
numberOfCribs: z.number(),
|
||||
@@ -423,8 +395,6 @@ export const getHotelDataSchema = z.object({
|
||||
hotelFacts: z.object({
|
||||
checkin: checkinSchema,
|
||||
ecoLabels: ecoLabelsSchema,
|
||||
hotelFacilityDetail: hotelFacilitySchema,
|
||||
hotelInformation: hotelInformationSchema,
|
||||
interior: interiorSchema,
|
||||
receptionHours: receptionHoursSchema,
|
||||
yearBuilt: z.string(),
|
||||
|
||||
@@ -5,12 +5,6 @@ export enum AvailabilityEnum {
|
||||
NotAvailable = "NotAvailable",
|
||||
}
|
||||
|
||||
export interface DetailedAmenity {
|
||||
name: string
|
||||
heading: string
|
||||
description: string
|
||||
}
|
||||
|
||||
export interface ReadMoreProps {
|
||||
label: string
|
||||
hotelId: string
|
||||
|
||||
Reference in New Issue
Block a user