From 6197c7634fc6e72d93bc76cf186934b45153b9f3 Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Mon, 24 Mar 2025 08:27:16 +0000 Subject: [PATCH] Merged in fix/destinationpages-loading-tweaks (pull request #1605) Suspense destination pages fixes and some performance improvements * Suspense destination pages fixes and some performance improvements Approved-by: Erik Tiekstra --- .../(live)/(public)/[contentType]/[uid]/page.tsx | 15 +++++++++++++-- .../Blocks/JoinScandicFriends/index.tsx | 9 +++++---- .../DestinationPage/DestinationCityPage/index.tsx | 7 ++++++- .../DestinationCountryPage/index.tsx | 3 ++- .../DestinationPage/TopImages/index.tsx | 1 + 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/[contentType]/[uid]/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/[contentType]/[uid]/page.tsx index 9a6ab5569..8c5552988 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/[contentType]/[uid]/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/[contentType]/[uid]/page.tsx @@ -1,5 +1,6 @@ import { headers } from "next/headers" import { notFound, redirect } from "next/navigation" +import { Suspense } from "react" import { overview } from "@/constants/routes/myPages" import { isSignupPage } from "@/constants/routes/signup" @@ -8,7 +9,9 @@ import { getHotelPage } from "@/lib/trpc/memoizedRequests" import { auth } from "@/auth" import DestinationCityPage from "@/components/ContentType/DestinationPage/DestinationCityPage" +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" @@ -62,9 +65,17 @@ export default async function ContentTypePage({ case PageContentTypeEnum.destinationOverviewPage: return case PageContentTypeEnum.destinationCountryPage: - return + return ( + }> + + + ) case PageContentTypeEnum.destinationCityPage: - return + return ( + }> + + + ) case PageContentTypeEnum.hotelPage: if (env.HIDE_FOR_NEXT_RELEASE) { return notFound() diff --git a/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx b/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx index 3fddc053d..6cc7514c6 100644 --- a/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx +++ b/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx @@ -1,5 +1,4 @@ -import { getProfileSafely } from "@/lib/trpc/memoizedRequests" - +import { auth } from "@/auth" import { SurpriseIcon } from "@/components/Icons" import Image from "@/components/Image" import Button from "@/components/TempDesignSystem/Button" @@ -7,6 +6,7 @@ import Link from "@/components/TempDesignSystem/Link" import BiroScript from "@/components/TempDesignSystem/Text/BiroScript" import Body from "@/components/TempDesignSystem/Text/Body" import Title from "@/components/TempDesignSystem/Text/Title" +import { isValidSession } from "@/utils/session" import styles from "./joinScandicFriends.module.css" @@ -19,8 +19,9 @@ interface JoinScandicFriendsProps { export default async function JoinScandicFriends({ content, }: JoinScandicFriendsProps) { - const session = await getProfileSafely() - if (session) { + const session = await auth() + const isLoggedIn = isValidSession(session) + if (isLoggedIn) { return null } diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx index a8504358a..98f050c2f 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx @@ -6,6 +6,7 @@ import { getDestinationCityPage } from "@/lib/trpc/memoizedRequests" import Blocks from "@/components/Blocks" import Breadcrumbs from "@/components/Breadcrumbs" +import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton" import ExperienceList from "../ExperienceList" import HotelDataContainer, { preload } from "../HotelDataContainer" @@ -49,7 +50,11 @@ export default async function DestinationCityPage() {
- + }> + + {images?.length && ( )} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx index cf5c3cb15..cb109137b 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx @@ -1,3 +1,4 @@ +import { notFound } from "next/navigation" import { Suspense } from "react" import { getDestinationCountryPage } from "@/lib/trpc/memoizedRequests" @@ -23,7 +24,7 @@ export default async function DestinationCountryPage() { const pageData = await getDestinationCountryPage() if (!pageData) { - return null + return notFound() } const { tracking, destinationCountryPage, translatedCountry } = pageData diff --git a/apps/scandic-web/components/ContentType/DestinationPage/TopImages/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/TopImages/index.tsx index 190e28432..584a74b51 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/TopImages/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/TopImages/index.tsx @@ -51,6 +51,7 @@ export default function TopImages({ images, destinationName }: TopImageProps) { ? setLightboxState({ open: true, activeIndex: index }) : null } + priority /> ) })}