diff --git a/apps/scandic-web/components/BookingWidget/Client.tsx b/apps/scandic-web/components/BookingWidget/Client.tsx
index 09cf4d697..ef7c99cab 100644
--- a/apps/scandic-web/components/BookingWidget/Client.tsx
+++ b/apps/scandic-web/components/BookingWidget/Client.tsx
@@ -41,7 +41,13 @@ export default function BookingWidgetClient({
const [isOpen, setIsOpen] = useState(false)
const bookingWidgetRef = useRef(null)
const lang = useLang()
- const [locations] = trpc.hotel.locations.get.useSuspenseQuery({ lang })
+ const {
+ data: locations,
+ isLoading,
+ isSuccess,
+ } = trpc.hotel.locations.get.useQuery({
+ lang,
+ })
useStickyPosition({
ref: bookingWidgetRef,
@@ -72,9 +78,9 @@ export default function BookingWidgetClient({
let selectedLocation: Location | null = null
if (params.hotelId) {
- selectedLocation = getLocationObj(locations, params.hotelId)
+ selectedLocation = getLocationObj(locations ?? [], params.hotelId)
} else if (params.city) {
- selectedLocation = getLocationObj(locations, params.city)
+ selectedLocation = getLocationObj(locations ?? [], params.city)
}
const selectedBookingCode = params.bookingCode ?? ""
@@ -173,6 +179,15 @@ export default function BookingWidgetClient({
}
}, [methods, selectedBookingCode])
+ if (isLoading) {
+ return
+ }
+
+ if (!isSuccess || !locations) {
+ // TODO: handle error cases
+ return null
+ }
+
return (