(null)
@@ -77,7 +77,7 @@ export default function HotelCardDialogListing({
return (
- {hotelsPinData?.length &&
+ {!!hotelsPinData?.length &&
hotelsPinData.map((data) => {
const isActive = data.name === activeCard
return (
diff --git a/components/HotelReservation/HotelCardDialogListing/utils.ts b/components/HotelReservation/HotelCardDialogListing/utils.ts
index 2299b3f35..1a0e05ad8 100644
--- a/components/HotelReservation/HotelCardDialogListing/utils.ts
+++ b/components/HotelReservation/HotelCardDialogListing/utils.ts
@@ -2,6 +2,8 @@ import type { HotelData } from "@/types/components/hotelReservation/selectHotel/
import type { HotelPin } from "@/types/components/hotelReservation/selectHotel/map"
export function getHotelPins(hotels: HotelData[]): HotelPin[] {
+ if (hotels.length === 0) return []
+
return hotels.map((hotel) => ({
coordinates: {
lat: hotel.hotelData.location.latitude,
diff --git a/components/Maps/StaticMap/index.tsx b/components/Maps/StaticMap/index.tsx
index 7c80aa01f..6db5eada3 100644
--- a/components/Maps/StaticMap/index.tsx
+++ b/components/Maps/StaticMap/index.tsx
@@ -5,6 +5,25 @@ import { getUrlWithSignature } from "@/utils/map"
import { StaticMapProps } from "@/types/components/maps/staticMap"
+function getCenter({
+ coordinates,
+ city,
+ country,
+}: {
+ coordinates?: { lat: number; lng: number }
+ city?: string
+ country?: string
+}): string | undefined {
+ switch (true) {
+ case !!coordinates:
+ return `${coordinates.lat},${coordinates.lng}`
+ case !!country:
+ return `${city}, ${country}`
+ default:
+ return city
+ }
+}
+
export default function StaticMap({
city,
country,
@@ -19,9 +38,7 @@ export default function StaticMap({
const key = env.GOOGLE_STATIC_MAP_KEY
const secret = env.GOOGLE_STATIC_MAP_SIGNATURE_SECRET
const baseUrl = "https://maps.googleapis.com/maps/api/staticmap"
- const center = coordinates
- ? `${coordinates.lat},${coordinates.lng}`
- : `${city}, ${country}`
+ const center = getCenter({ coordinates, city, country })
if (!center) {
return null
diff --git a/lib/trpc/memoizedRequests/index.ts b/lib/trpc/memoizedRequests/index.ts
index 7db2e66da..2bf35c264 100644
--- a/lib/trpc/memoizedRequests/index.ts
+++ b/lib/trpc/memoizedRequests/index.ts
@@ -144,7 +144,7 @@ export const getBookingConfirmation = cache(
export const getCityCoordinates = cache(
async function getMemoizedCityCoordinates(input: {
city: string
- hotel: { address: string }
+ hotel: { address: string | undefined }
}) {
return serverClient().hotel.map.city(input)
}
diff --git a/server/routers/hotels/input.ts b/server/routers/hotels/input.ts
index a4e47caf3..4a66009b3 100644
--- a/server/routers/hotels/input.ts
+++ b/server/routers/hotels/input.ts
@@ -77,6 +77,6 @@ export const getRoomPackagesInputSchema = z.object({
export const getCityCoordinatesInputSchema = z.object({
city: z.string(),
hotel: z.object({
- address: z.string(),
+ address: z.string().optional(),
}),
})
diff --git a/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts b/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts
index 68a6174ed..eb84b6977 100644
--- a/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts
+++ b/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts
@@ -18,3 +18,7 @@ export type HotelData = {
hotelData: Hotel
price: ProductType
}
+
+export interface NullableHotelData extends Omit {
+ hotelData: HotelData["hotelData"] | null
+}
diff --git a/types/components/hotelReservation/selectHotel/map.ts b/types/components/hotelReservation/selectHotel/map.ts
index 4ec21f86f..19490464d 100644
--- a/types/components/hotelReservation/selectHotel/map.ts
+++ b/types/components/hotelReservation/selectHotel/map.ts
@@ -56,7 +56,7 @@ export interface HotelCardDialogProps {
}
export interface HotelCardDialogListingProps {
- hotels: HotelData[]
+ hotels: HotelData[] | null
activeCard: string | null | undefined
onActiveCardChange: (hotelName: string | null) => void
}