From c2e521035bf2824755fc32797d2ff46f4fabcec1 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Fri, 30 Aug 2024 15:46:36 +0200 Subject: [PATCH] feat(SW-237): Updated parallel route to the root layout --- .../@bookingwidget/[...path]/page.tsx | 5 ----- .../my-pages/@bookingwidget/default.tsx | 3 --- .../(live)/(protected)/my-pages/layout.tsx | 17 ++++++---------- .../(public)/[contentType]/[uid]/layout.tsx | 13 ++++-------- .../(public)/hotelreservation/layout.tsx | 9 +-------- .../(live)/@bookingwidget/[...paths]/page.tsx | 1 + app/[lang]/(live)/@bookingwidget/default.tsx | 1 + app/[lang]/(live)/@bookingwidget/page.tsx | 20 +++++++++++++++++++ app/[lang]/(live)/layout.tsx | 3 +++ components/BookingWidget/index.tsx | 19 +++--------------- 10 files changed, 39 insertions(+), 52 deletions(-) delete mode 100644 app/[lang]/(live)/(protected)/my-pages/@bookingwidget/[...path]/page.tsx delete mode 100644 app/[lang]/(live)/(protected)/my-pages/@bookingwidget/default.tsx create mode 100644 app/[lang]/(live)/@bookingwidget/[...paths]/page.tsx create mode 100644 app/[lang]/(live)/@bookingwidget/default.tsx create mode 100644 app/[lang]/(live)/@bookingwidget/page.tsx diff --git a/app/[lang]/(live)/(protected)/my-pages/@bookingwidget/[...path]/page.tsx b/app/[lang]/(live)/(protected)/my-pages/@bookingwidget/[...path]/page.tsx deleted file mode 100644 index 487bfcb5d..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/@bookingwidget/[...path]/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import BookingWidget from "@/components/BookingWidget" - -export default function BookingWidgetPage() { - return -} diff --git a/app/[lang]/(live)/(protected)/my-pages/@bookingwidget/default.tsx b/app/[lang]/(live)/(protected)/my-pages/@bookingwidget/default.tsx deleted file mode 100644 index ad1e716a6..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/@bookingwidget/default.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function DefaultBookingWidgetPage() { - return null -} diff --git a/app/[lang]/(live)/(protected)/my-pages/layout.tsx b/app/[lang]/(live)/(protected)/my-pages/layout.tsx index bc2d1fe2d..9677f014b 100644 --- a/app/[lang]/(live)/(protected)/my-pages/layout.tsx +++ b/app/[lang]/(live)/(protected)/my-pages/layout.tsx @@ -3,23 +3,18 @@ import Sidebar from "@/components/MyPages/Sidebar" import styles from "./layout.module.css" export default async function MyPagesLayout({ - bookingwidget, breadcrumbs, children, }: React.PropsWithChildren<{ - bookingwidget: React.ReactNode breadcrumbs: React.ReactNode }>) { return ( - <> - {bookingwidget} -
- {breadcrumbs} -
- - {children} -
+
+ {breadcrumbs} +
+ + {children}
- +
) } diff --git a/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx b/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx index 28d7ed59c..15fe17b28 100644 --- a/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx +++ b/app/[lang]/(live)/(public)/[contentType]/[uid]/layout.tsx @@ -1,5 +1,3 @@ -import BookingWidget from "@/components/BookingWidget" - import styles from "./layout.module.css" import { @@ -18,12 +16,9 @@ export default function ContentTypeLayout({ } >) { return ( - <> - -
- {breadcrumbs} - {children} -
- +
+ {breadcrumbs} + {children} +
) } diff --git a/app/[lang]/(live)/(public)/hotelreservation/layout.tsx b/app/[lang]/(live)/(public)/hotelreservation/layout.tsx index a5fce013f..ee96f3c10 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/layout.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/layout.tsx @@ -1,5 +1,3 @@ -import BookingWidget from "@/components/BookingWidget" - import styles from "./layout.module.css" import { LangParams, LayoutArgs } from "@/types/params" @@ -7,10 +5,5 @@ import { LangParams, LayoutArgs } from "@/types/params" export default function HotelReservationLayout({ children, }: React.PropsWithChildren>) { - return ( - <> - -
{children}
- - ) + return
{children}
} diff --git a/app/[lang]/(live)/@bookingwidget/[...paths]/page.tsx b/app/[lang]/(live)/@bookingwidget/[...paths]/page.tsx new file mode 100644 index 000000000..03a82e5f5 --- /dev/null +++ b/app/[lang]/(live)/@bookingwidget/[...paths]/page.tsx @@ -0,0 +1 @@ +export { default } from "../page" diff --git a/app/[lang]/(live)/@bookingwidget/default.tsx b/app/[lang]/(live)/@bookingwidget/default.tsx new file mode 100644 index 000000000..83ec2818e --- /dev/null +++ b/app/[lang]/(live)/@bookingwidget/default.tsx @@ -0,0 +1 @@ +export { default } from "./page" diff --git a/app/[lang]/(live)/@bookingwidget/page.tsx b/app/[lang]/(live)/@bookingwidget/page.tsx new file mode 100644 index 000000000..33a43d76c --- /dev/null +++ b/app/[lang]/(live)/@bookingwidget/page.tsx @@ -0,0 +1,20 @@ +import { serverClient } from "@/lib/trpc/server" + +import BookingWidget from "@/components/BookingWidget" +import { getLang } from "@/i18n/serverContext" + +export default async function BookingWidgetPage() { + // Get the booking widget show/hide status based on page specific settings + const bookingWidgetToggle = + await serverClient().contentstack.base.page_settings({ + lang: getLang(), + }) + + return ( + <> + {bookingWidgetToggle && bookingWidgetToggle.hideBookingWidget ? null : ( + + )} + + ) +} diff --git a/app/[lang]/(live)/layout.tsx b/app/[lang]/(live)/layout.tsx index 77911e187..3ee99194c 100644 --- a/app/[lang]/(live)/layout.tsx +++ b/app/[lang]/(live)/layout.tsx @@ -21,9 +21,11 @@ export default async function RootLayout({ children, params, header, + bookingwidget, }: React.PropsWithChildren< LayoutArgs & { header: React.ReactNode + bookingwidget: React.ReactNode } >) { setLang(params.lang) @@ -52,6 +54,7 @@ export default async function RootLayout({ {header} + {bookingwidget} {children}