diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/Client.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/Client.tsx
index 686bdceb5..2e82511df 100644
--- a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/Client.tsx
+++ b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Previous/Client.tsx
@@ -36,22 +36,21 @@ export default function ClientPreviousStays({
}
)
+ if (isLoading) {
+ return
+ }
+
function loadMoreData() {
if (hasNextPage) {
fetchNextPage()
}
}
- // TS having a hard time with the filtered type.
- // This is only temporary as we will not return null
- // later on when we handle errors appropriately.
- const filteredStays = (data?.pages.filter((page) => page?.data) ??
- []) as unknown as PreviousStaysNonNullResponseObject[]
- const stays = filteredStays.flatMap((page) => page.data)
+ const stays = data.pages
+ .filter((page): page is PreviousStaysNonNullResponseObject => !!page?.data)
+ .flatMap((page) => page.data)
- return isLoading ? (
-
- ) : (
+ return (
{stays.map((stay) => (
diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/Client.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/Client.tsx
index b793159b6..84c9a01db 100644
--- a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/Client.tsx
+++ b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/Client.tsx
@@ -36,22 +36,21 @@ export default function ClientUpcomingStays({
}
)
+ if (isLoading) {
+ return
+ }
+
function loadMoreData() {
if (hasNextPage) {
fetchNextPage()
}
}
- // TS having a hard time with the filtered type.
- // This is only temporary as we will not return null
- // later on when we handle errors appropriately.
- const filteredStays = (data?.pages.filter((page) => page && page.data) ??
- []) as unknown as UpcomingStaysNonNullResponseObject[]
- const stays = filteredStays.flatMap((page) => page.data)
+ const stays = data.pages
+ .filter((page): page is UpcomingStaysNonNullResponseObject => !!page?.data)
+ .flatMap((page) => page.data)
- return isLoading ? (
-
- ) : stays.length ? (
+ return stays.length ? (
{stays.map((stay) => (