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