From 800b3299983104bd50d98359fad36dd3d990b017 Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Wed, 4 Jun 2025 06:26:42 +0000 Subject: [PATCH] Merged in fix/my-stay-webview-3 (pull request #2281) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat/my-stay-webview - check if user else redirect to refresh page * feat/my-stay-webview - check if user else redirect to refresh page Approved-by: Joakim Jäderberg --- .../(views)/[contentType]/[uid]/page.tsx | 28 +++++++++++++++++++ .../{ => (views)}/hotelreservation/README.md | 0 .../{ => (views)}/hotelreservation/layout.tsx | 2 +- .../hotelreservation/my-stay/loading.tsx | 0 .../hotelreservation/my-stay/page.module.css | 0 .../hotelreservation/my-stay/page.tsx | 0 .../hotelreservation/my-stay/tracking.tsx | 0 .../[uid]/page.tsx => (views)/layout.tsx} | 28 +++++-------------- 8 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 apps/scandic-web/app/[lang]/webview/(views)/[contentType]/[uid]/page.tsx rename apps/scandic-web/app/[lang]/webview/{ => (views)}/hotelreservation/README.md (100%) rename apps/scandic-web/app/[lang]/webview/{ => (views)}/hotelreservation/layout.tsx (92%) rename apps/scandic-web/app/[lang]/webview/{ => (views)}/hotelreservation/my-stay/loading.tsx (100%) rename apps/scandic-web/app/[lang]/webview/{ => (views)}/hotelreservation/my-stay/page.module.css (100%) rename apps/scandic-web/app/[lang]/webview/{ => (views)}/hotelreservation/my-stay/page.tsx (100%) rename apps/scandic-web/app/[lang]/webview/{ => (views)}/hotelreservation/my-stay/tracking.tsx (100%) rename apps/scandic-web/app/[lang]/webview/{[contentType]/[uid]/page.tsx => (views)/layout.tsx} (68%) diff --git a/apps/scandic-web/app/[lang]/webview/(views)/[contentType]/[uid]/page.tsx b/apps/scandic-web/app/[lang]/webview/(views)/[contentType]/[uid]/page.tsx new file mode 100644 index 000000000..76b5871ef --- /dev/null +++ b/apps/scandic-web/app/[lang]/webview/(views)/[contentType]/[uid]/page.tsx @@ -0,0 +1,28 @@ +import { notFound } from "next/navigation" + +import AccountPage from "@/components/Webviews/AccountPage" +import LoyaltyPage from "@/components/Webviews/LoyaltyPage" + +import type { + ContentTypeWebviewParams, + LangParams, + PageArgs, + UIDParams, +} from "@/types/params" + +export default async function ContentTypePage( + props: PageArgs +) { + const params = await props.params + + switch (params.contentType) { + case "loyalty-page": + return + case "account-page": + return + default: + const type: never = params.contentType + console.error(`Unsupported content type given: ${type}`) + notFound() + } +} diff --git a/apps/scandic-web/app/[lang]/webview/hotelreservation/README.md b/apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/README.md similarity index 100% rename from apps/scandic-web/app/[lang]/webview/hotelreservation/README.md rename to apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/README.md diff --git a/apps/scandic-web/app/[lang]/webview/hotelreservation/layout.tsx b/apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/layout.tsx similarity index 92% rename from apps/scandic-web/app/[lang]/webview/hotelreservation/layout.tsx rename to apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/layout.tsx index 1b3f9ee9f..9ec90c6f9 100644 --- a/apps/scandic-web/app/[lang]/webview/hotelreservation/layout.tsx +++ b/apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/layout.tsx @@ -3,7 +3,7 @@ import { env } from "@/env/server" import type { LangParams, PageArgs } from "@/types/params" export async function generateMetadata(props: PageArgs) { - const params = await props.params; + const params = await props.params return { robots: { index: env.isLangLive(params.lang), diff --git a/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/loading.tsx b/apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/loading.tsx similarity index 100% rename from apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/loading.tsx rename to apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/loading.tsx diff --git a/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.module.css b/apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/page.module.css similarity index 100% rename from apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.module.css rename to apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/page.module.css diff --git a/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.tsx b/apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/page.tsx similarity index 100% rename from apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.tsx rename to apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/page.tsx diff --git a/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/tracking.tsx b/apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/tracking.tsx similarity index 100% rename from apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/tracking.tsx rename to apps/scandic-web/app/[lang]/webview/(views)/hotelreservation/my-stay/tracking.tsx diff --git a/apps/scandic-web/app/[lang]/webview/[contentType]/[uid]/page.tsx b/apps/scandic-web/app/[lang]/webview/(views)/layout.tsx similarity index 68% rename from apps/scandic-web/app/[lang]/webview/[contentType]/[uid]/page.tsx rename to apps/scandic-web/app/[lang]/webview/(views)/layout.tsx index 3b1d48cff..fab9288b8 100644 --- a/apps/scandic-web/app/[lang]/webview/[contentType]/[uid]/page.tsx +++ b/apps/scandic-web/app/[lang]/webview/(views)/layout.tsx @@ -1,23 +1,18 @@ import { headers } from "next/headers" -import { notFound, redirect } from "next/navigation" +import { redirect } from "next/navigation" import { getProfile } from "@/lib/trpc/memoizedRequests" -import AccountPage from "@/components/Webviews/AccountPage" -import LoyaltyPage from "@/components/Webviews/LoyaltyPage" import { getIntl } from "@/i18n" -import type { - ContentTypeWebviewParams, - LangParams, - PageArgs, - UIDParams, -} from "@/types/params" +import type { LangParams, LayoutArgs } from "@/types/params" -export default async function ContentTypePage( - props: PageArgs +export default async function Layout( + props: React.PropsWithChildren> ) { const params = await props.params + + const { children } = props const intl = await getIntl() const user = await getProfile() @@ -64,14 +59,5 @@ export default async function ContentTypePage( } } - switch (params.contentType) { - case "loyalty-page": - return - case "account-page": - return - default: - const type: never = params.contentType - console.error(`Unsupported content type given: ${type}`) - notFound() - } + return <>{children} }