fix(SW-1111) refactor state of active hotel card and hotel pin

This commit is contained in:
Pontus Dreij
2024-12-09 16:49:15 +01:00
parent 7f50d34431
commit 15c5afc43a
15 changed files with 108 additions and 115 deletions

View File

@@ -14,26 +14,18 @@ import type {
HotelData,
NullableHotelData,
} from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams"
import type { Location } from "@/types/trpc/routers/hotel/locations"
import type { SelectHotelMapContainerProps } from "@/types/components/hotelReservation/selectHotel/map"
function isHotelData(hotel: NullableHotelData): hotel is HotelData {
function isValidHotelData(hotel: NullableHotelData): hotel is HotelData {
return hotel !== null && hotel !== undefined
}
type Props = {
city: Location
searchParams: SelectHotelSearchParams
adultsInRoom: number
childrenInRoom: string | undefined
}
export async function SelectHotelMapContainer({
city,
searchParams,
adultsInRoom,
childrenInRoom,
}: Props) {
}: SelectHotelMapContainerProps) {
const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID
const googleMapsApiKey = env.GOOGLE_STATIC_MAP_KEY
@@ -47,15 +39,9 @@ export async function SelectHotelMapContainer({
})
)
const [hotels, hotelsError] = await fetchAvailableHotelsPromise
const [hotels] = await fetchAvailableHotelsPromise
if (hotelsError) {
// TODO: show proper error component
console.error("[SelectHotelMapContainer] unable to fetch hotels")
return null
}
const validHotels = hotels?.filter(isHotelData) || []
const validHotels = hotels?.filter(isValidHotelData) || []
const hotelPins = getHotelPins(validHotels)
const filterList = getFiltersFromHotels(validHotels)