feat(SW-251): check for undefined
This commit is contained in:
@@ -28,6 +28,8 @@ export default async function SelectHotelPage({
|
|||||||
|
|
||||||
if (!getHotelFitlers) return null
|
if (!getHotelFitlers) return null
|
||||||
|
|
||||||
|
const { filters } = getHotelFitlers
|
||||||
|
|
||||||
const getAvailableHotels = await serverClient().hotel.availability.get({
|
const getAvailableHotels = 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",
|
||||||
@@ -54,7 +56,7 @@ export default async function SelectHotelPage({
|
|||||||
{intl.formatMessage({ id: "Show map" })}
|
{intl.formatMessage({ id: "Show map" })}
|
||||||
<ChevronRightIcon color="burgundy" />
|
<ChevronRightIcon color="burgundy" />
|
||||||
</Link>
|
</Link>
|
||||||
{/* <HotelFilter filters={hotelFilters} /> */}
|
<HotelFilter filters={filters} />
|
||||||
</section>
|
</section>
|
||||||
<section className={styles.hotelCards}>
|
<section className={styles.hotelCards}>
|
||||||
{availability.length ? (
|
{availability.length ? (
|
||||||
|
|||||||
@@ -4,25 +4,20 @@ import styles from "./hotelFilter.module.css"
|
|||||||
|
|
||||||
import { HotelFilterProps } from "@/types/components/hotelReservation/selectHotel/hotelFilterProps"
|
import { HotelFilterProps } from "@/types/components/hotelReservation/selectHotel/hotelFilterProps"
|
||||||
|
|
||||||
export default async function HotelFilter({
|
export default async function HotelFilter({ filters }: HotelFilterProps) {
|
||||||
hotelId,
|
|
||||||
filters,
|
|
||||||
}: HotelFilterProps) {
|
|
||||||
const { formatMessage } = await getIntl()
|
const { formatMessage } = await getIntl()
|
||||||
|
|
||||||
|
console.log(filters)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className={styles.container}>
|
<aside className={styles.container}>
|
||||||
<div className={styles.facilities}>
|
<div className={styles.facilities}>
|
||||||
{formatMessage({ id: "Room facilities" })}
|
{formatMessage({ id: "Hotel facilities" })}
|
||||||
{/* {filters.roomFacilities.map((roomFilter) => (
|
{filters.map((data) => (
|
||||||
<div key={roomFilter} className={styles.filter}>
|
<div key={data.id}>{data.name}</div>
|
||||||
<input id={roomFilter} name={roomFilter} type="checkbox" />
|
))}
|
||||||
<label htmlFor={roomFilter}>{roomFilter}</label>
|
|
||||||
</div>
|
|
||||||
))} */}
|
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.facilities}>
|
<div className={styles.facilities}>
|
||||||
{formatMessage({ id: "Hotel facilities" })}
|
|
||||||
{/* {filters.hotelFacilities.map((hotelFilter) => (
|
{/* {filters.hotelFacilities.map((hotelFilter) => (
|
||||||
<div key={hotelFilter} className={styles.filter}>
|
<div key={hotelFilter} className={styles.filter}>
|
||||||
<input id={hotelFilter} name={hotelFilter} type="checkbox" />
|
<input id={hotelFilter} name={hotelFilter} type="checkbox" />
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import {
|
|||||||
getHotelDataSchema,
|
getHotelDataSchema,
|
||||||
getHotelFilterSchema,
|
getHotelFilterSchema,
|
||||||
getRatesSchema,
|
getRatesSchema,
|
||||||
|
HotelFilters,
|
||||||
roomSchema,
|
roomSchema,
|
||||||
} from "./output"
|
} from "./output"
|
||||||
import tempRatesData from "./tempRatesData.json"
|
import tempRatesData from "./tempRatesData.json"
|
||||||
@@ -519,13 +520,12 @@ export const hotelQueryRouter = router({
|
|||||||
const filters = hotelData.flatMap(
|
const filters = hotelData.flatMap(
|
||||||
(data) => data.attributes.detailedFacilities
|
(data) => data.attributes.detailedFacilities
|
||||||
)
|
)
|
||||||
const unieqId = [...new Set(filters.map((data) => data.id))]
|
const unieqeFilters = [...new Set(filters.map((data) => data.id))]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hotelId: hotelData.map((data) => data.id),
|
filters: unieqeFilters
|
||||||
filters: unieqId.map((data) =>
|
.map((data) => filters.find((find) => find.id === data))
|
||||||
filters.find((find) => find.id === data)
|
.filter((filter) => filter !== undefined) as HotelFilters,
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { HotelFilters, HotelId } from "@/server/routers/hotels/output"
|
import { HotelFilters } from "@/server/routers/hotels/output"
|
||||||
|
|
||||||
export type HotelFilterProps = {
|
export type HotelFilterProps = {
|
||||||
hotelId: HotelId
|
|
||||||
filters: HotelFilters
|
filters: HotelFilters
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user