fix: improve loading on destination overview page

- Only load data from Contentstack
- Use static JSON for destination list
- Some logic improvements to data handling and types
This commit is contained in:
Michael Zetterberg
2025-03-26 11:38:10 +01:00
parent f010a6869a
commit 65f75c11ef
37 changed files with 6619 additions and 185 deletions

View File

@@ -12,7 +12,6 @@ import DestinationCityPage from "@/components/ContentType/DestinationPage/Destin
import DestinationCityPageSkeleton from "@/components/ContentType/DestinationPage/DestinationCityPage/DestinationCityPageSkeleton"
import DestinationCountryPage from "@/components/ContentType/DestinationPage/DestinationCountryPage"
import DestinationCountryPageSkeleton from "@/components/ContentType/DestinationPage/DestinationCountryPage/DestinationCountryPageSkeleton"
import DestinationOverviewPage from "@/components/ContentType/DestinationPage/DestinationOverviewPage"
import HotelPage from "@/components/ContentType/HotelPage"
import HotelSubpage from "@/components/ContentType/HotelSubpage"
import LoyaltyPage from "@/components/ContentType/LoyaltyPage"
@@ -23,8 +22,8 @@ import { getLang } from "@/i18n/serverContext"
import { isValidSession } from "@/utils/session"
import type {
ContentTypeParams,
LangParams,
NonAppRouterContentTypeParams,
PageArgs,
UIDParams,
} from "@/types/params"
@@ -36,7 +35,7 @@ export default async function ContentTypePage({
params,
searchParams,
}: PageArgs<
LangParams & ContentTypeParams & UIDParams,
LangParams & NonAppRouterContentTypeParams & UIDParams,
{ subpage?: string; filterFromUrl?: string }
>) {
const pathname = headers().get("x-pathname") || ""
@@ -62,11 +61,6 @@ export default async function ContentTypePage({
}
case PageContentTypeEnum.loyaltyPage:
return <LoyaltyPage />
case PageContentTypeEnum.destinationOverviewPage:
if (env.HIDE_FOR_NEXT_RELEASE) {
return notFound()
}
return <DestinationOverviewPage />
case PageContentTypeEnum.destinationCountryPage:
if (env.HIDE_FOR_NEXT_RELEASE) {
return notFound()

View File

@@ -0,0 +1,3 @@
export default function DestinationOverviewPageBreadcrumbs() {
return null
}

View File

@@ -0,0 +1 @@
export { default } from "../../../[contentType]/[uid]/@preview/loading"

View File

@@ -0,0 +1 @@
export { default } from "../../../[contentType]/[uid]/@preview/page"

View File

@@ -0,0 +1,37 @@
"use client"
import * as Sentry from "@sentry/nextjs"
import { useEffect } from "react"
import { useIntl } from "react-intl"
import { DestinationOverviewPageError } from "@/components/ContentType/DestinationPage/DestinationOverviewPage/error"
export default function Error({
error,
}: {
error: Error & { digest?: string }
}) {
const intl = useIntl()
useEffect(() => {
if (!error) return
console.error(error)
Sentry.captureException(error)
}, [error])
return (
<DestinationOverviewPageError>
<p>
<strong>
{intl.formatMessage(
{ id: "An error occurred ({errorId})" },
{
errorId: `${error.digest}@${Date.now()}`,
}
)}
</strong>
</p>
</DestinationOverviewPageError>
)
}

View File

@@ -0,0 +1 @@
export { default } from "../../[contentType]/[uid]/layout"

View File

@@ -0,0 +1 @@
export { DestinationOverviewPageLoading as default } from "@/components/ContentType/DestinationPage/DestinationOverviewPage"

View File

@@ -0,0 +1,15 @@
import { notFound } from "next/navigation"
import { env } from "@/env/server"
import DestinationOverviewPage from "@/components/ContentType/DestinationPage/DestinationOverviewPage"
export { generateMetadata } from "@/utils/generateMetadata"
export default function DestinationOverviewPagePage() {
if (env.HIDE_FOR_NEXT_RELEASE) {
return notFound()
}
return <DestinationOverviewPage />
}