From 4e4b6f1bd64a591121ace9906827ba7567ae5ea9 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Tue, 20 Feb 2024 09:14:42 +0100 Subject: [PATCH] feat: separate current and "new" web in route groups --- app/[lang]/(live)/content-page/page.tsx | 57 +++++++++++++ app/[lang]/(live)/layout.tsx | 38 --------- .../current-content-page/page.tsx | 2 +- app/[lang]/(live-current)/layout.tsx | 79 +++++++++++++++++++ app/[lang]/(live-current)/not-found.tsx | 8 ++ app/[lang]/(preview)/layout.tsx | 25 ------ app/[lang]/(preview)/preview/page.tsx | 2 +- app/[lang]/(preview-current)/error.tsx | 9 +++ app/[lang]/(preview-current)/layout.tsx | 56 +++++++++++++ app/[lang]/(preview-current)/not-found.tsx | 8 ++ .../preview-current/page.tsx | 45 +++++++++++ middleware.ts | 5 +- {app => public/Static/css}/core.css | 0 {app => public/Static/css}/scandic.css | 0 14 files changed, 268 insertions(+), 66 deletions(-) create mode 100644 app/[lang]/(live)/content-page/page.tsx rename app/[lang]/{(live) => (live-current)}/current-content-page/page.tsx (100%) create mode 100644 app/[lang]/(live-current)/layout.tsx create mode 100644 app/[lang]/(live-current)/not-found.tsx create mode 100644 app/[lang]/(preview-current)/error.tsx create mode 100644 app/[lang]/(preview-current)/layout.tsx create mode 100644 app/[lang]/(preview-current)/not-found.tsx create mode 100644 app/[lang]/(preview-current)/preview-current/page.tsx rename {app => public/Static/css}/core.css (100%) rename {app => public/Static/css}/scandic.css (100%) diff --git a/app/[lang]/(live)/content-page/page.tsx b/app/[lang]/(live)/content-page/page.tsx new file mode 100644 index 000000000..9961118e4 --- /dev/null +++ b/app/[lang]/(live)/content-page/page.tsx @@ -0,0 +1,57 @@ +import { notFound } from "next/navigation" + +import { request } from "@/lib/request" +import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql" + +import ContentPageComponent from "@/components/Current/ContentPage" + +import type { PageArgs, LangParams, UriParams } from "@/types/params" +import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage" +import Tracking from "../../Tracking" + +export default async function ContentPage({ + params, + searchParams, +}: PageArgs) { + try { + if (!searchParams.uri) { + throw new Error("Bad URI") + } + + const response = await request( + GetCurrentBlockPage, + { + locale: params.lang, + url: searchParams.uri, + } + ) + + if (!response.data?.all_current_blocks_page?.total) { + console.log("#### DATA ####") + console.log(response.data) + console.log("SearchParams URI: ", searchParams.uri) + throw new Error("Not found") + } + const pageData = response.data.all_current_blocks_page.items[0] + const trackingData = { + pageName: pageData.title, + pageType: pageData.__typename, + publishedDate: pageData.system.updated_at, + createdDate: pageData.system.created_at, + pageId: pageData.system.uid, + } + + return ( + <> + + + + ) + } catch (err) { + return notFound() + } +} diff --git a/app/[lang]/(live)/layout.tsx b/app/[lang]/(live)/layout.tsx index c168eeb3e..58894d379 100644 --- a/app/[lang]/(live)/layout.tsx +++ b/app/[lang]/(live)/layout.tsx @@ -1,10 +1,4 @@ -import "../../core.css" -import "../../scandic.css" - -import Footer from "@/components/Current/Footer" -import LangPopup from "@/components/Current/LangPopup" import Script from "next/script" -import SkipToMainContent from "@/components/SkipToMainContent" import type { Metadata } from "next" import type { LangParams, LayoutArgs } from "@/types/params" @@ -33,42 +27,10 @@ export default function RootLayout({ id="Cookiebot" src="https://consent.cookiebot.com/uc.js" /> - {/* diff --git a/app/[lang]/(live)/current-content-page/page.tsx b/app/[lang]/(live-current)/current-content-page/page.tsx similarity index 100% rename from app/[lang]/(live)/current-content-page/page.tsx rename to app/[lang]/(live-current)/current-content-page/page.tsx index de9faf0e1..6fdb41531 100644 --- a/app/[lang]/(live)/current-content-page/page.tsx +++ b/app/[lang]/(live-current)/current-content-page/page.tsx @@ -4,10 +4,10 @@ import { request } from "@/lib/request" import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql" import ContentPage from "@/components/Current/ContentPage" +import Tracking from "../../Tracking" import type { PageArgs, LangParams, UriParams } from "@/types/params" import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage" -import Tracking from "../../Tracking" export default async function CurrentContentPage({ params, diff --git a/app/[lang]/(live-current)/layout.tsx b/app/[lang]/(live-current)/layout.tsx new file mode 100644 index 000000000..529c754fe --- /dev/null +++ b/app/[lang]/(live-current)/layout.tsx @@ -0,0 +1,79 @@ +/* eslint-disable @next/next/no-css-tags */ + +import Footer from "@/components/Current/Footer" +import LangPopup from "@/components/Current/LangPopup" +import Script from "next/script" +import SkipToMainContent from "@/components/SkipToMainContent" +import AdobeScript from "../AdobeScript" + +import type { Metadata } from "next" +import type { LangParams, LayoutArgs } from "@/types/params" + +export const metadata: Metadata = { + description: "New web", + title: "Scandic Hotels New Web", +} + +export default function RootLayout({ + children, + params, +}: React.PropsWithChildren>) { + return ( + + + + + + + + ) +} diff --git a/app/[lang]/(live-current)/not-found.tsx b/app/[lang]/(live-current)/not-found.tsx new file mode 100644 index 000000000..1a6cc1ce6 --- /dev/null +++ b/app/[lang]/(live-current)/not-found.tsx @@ -0,0 +1,8 @@ +export default function NotFound() { + return ( +
+

Not Found

+

Could not find requested resource

+
+ ) +} diff --git a/app/[lang]/(preview)/layout.tsx b/app/[lang]/(preview)/layout.tsx index e7d4ad7bd..3d786561c 100644 --- a/app/[lang]/(preview)/layout.tsx +++ b/app/[lang]/(preview)/layout.tsx @@ -21,34 +21,9 @@ export default function RootLayout({ }: React.PropsWithChildren>) { return ( - -