feat(SW-237): Implemented page based toggle for BW
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
import BookingWidgetContainer from "@/components/BookingWidgetContainer"
|
||||||
|
|
||||||
|
export default function BookingWidgetPage() {
|
||||||
|
return <BookingWidgetContainer />
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default function DefaultBookingWidgetPage() {
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -3,18 +3,23 @@ import Sidebar from "@/components/MyPages/Sidebar"
|
|||||||
import styles from "./layout.module.css"
|
import styles from "./layout.module.css"
|
||||||
|
|
||||||
export default async function MyPagesLayout({
|
export default async function MyPagesLayout({
|
||||||
|
bookingwidget,
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
children,
|
children,
|
||||||
}: React.PropsWithChildren & {
|
}: React.PropsWithChildren & {
|
||||||
|
bookingwidget: React.ReactNode
|
||||||
breadcrumbs: React.ReactNode
|
breadcrumbs: React.ReactNode
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className={styles.layout}>
|
<>
|
||||||
{breadcrumbs}
|
{bookingwidget}
|
||||||
<section className={styles.content}>
|
<section className={styles.layout}>
|
||||||
<Sidebar />
|
{breadcrumbs}
|
||||||
{children}
|
<section className={styles.content}>
|
||||||
|
<Sidebar />
|
||||||
|
{children}
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import BookingWidgetContainer from "@/components/BookingWidgetContainer"
|
||||||
|
|
||||||
import styles from "./layout.module.css"
|
import styles from "./layout.module.css"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -16,9 +18,12 @@ export default function ContentTypeLayout({
|
|||||||
}
|
}
|
||||||
>) {
|
>) {
|
||||||
return (
|
return (
|
||||||
<section className={styles.layout}>
|
<>
|
||||||
{breadcrumbs}
|
<BookingWidgetContainer />
|
||||||
{children}
|
<section className={styles.layout}>
|
||||||
</section>
|
{breadcrumbs}
|
||||||
|
{children}
|
||||||
|
</section>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import BookingWidgetContainer from "@/components/BookingWidgetContainer"
|
||||||
|
|
||||||
import styles from "./layout.module.css"
|
import styles from "./layout.module.css"
|
||||||
|
|
||||||
import { LangParams, LayoutArgs } from "@/types/params"
|
import { LangParams, LayoutArgs } from "@/types/params"
|
||||||
@@ -5,5 +7,10 @@ import { LangParams, LayoutArgs } from "@/types/params"
|
|||||||
export default function HotelReservationLayout({
|
export default function HotelReservationLayout({
|
||||||
children,
|
children,
|
||||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||||
return <div className={styles.layout}>{children}</div>
|
return (
|
||||||
|
<>
|
||||||
|
<BookingWidgetContainer />
|
||||||
|
<div className={styles.layout}>{children}</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import "@scandic-hotels/design-system/style.css"
|
|||||||
import Script from "next/script"
|
import Script from "next/script"
|
||||||
|
|
||||||
import TokenRefresher from "@/components/Auth/TokenRefresher"
|
import TokenRefresher from "@/components/Auth/TokenRefresher"
|
||||||
|
import BookingWidgetContainer from "@/components/BookingWidgetContainer"
|
||||||
import AdobeScript from "@/components/Current/AdobeScript"
|
import AdobeScript from "@/components/Current/AdobeScript"
|
||||||
import Footer from "@/components/Current/Footer"
|
import Footer from "@/components/Current/Footer"
|
||||||
import Header from "@/components/Current/Header"
|
import Header from "@/components/Current/Header"
|
||||||
@@ -71,6 +72,7 @@ export default async function RootLayout({
|
|||||||
myPagesMobileDropdown={myPagesMobileDropdown}
|
myPagesMobileDropdown={myPagesMobileDropdown}
|
||||||
languageSwitcher={languageSwitcher}
|
languageSwitcher={languageSwitcher}
|
||||||
/>
|
/>
|
||||||
|
<BookingWidgetContainer />
|
||||||
{children}
|
{children}
|
||||||
<Footer />
|
<Footer />
|
||||||
<TokenRefresher />
|
<TokenRefresher />
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import Form from "../Forms/BookingWidget"
|
|
||||||
|
|
||||||
import styles from "./bookingWidget.module.css"
|
|
||||||
|
|
||||||
export function BookingWidget() {
|
|
||||||
return (
|
|
||||||
<section className={styles.container}>
|
|
||||||
<Form />
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
23
components/BookingWidgetContainer/index.tsx
Normal file
23
components/BookingWidgetContainer/index.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
import { getLang } from "@/i18n/serverContext"
|
||||||
|
|
||||||
|
import Form from "@/components/Forms/BookingWidget"
|
||||||
|
import styles from "./bookingWidget.module.css"
|
||||||
|
|
||||||
|
export default async function BookingWidgetContainer() {
|
||||||
|
// 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 : (
|
||||||
|
<section className={styles.container}>
|
||||||
|
<Form />
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import { homeHrefs } from "@/constants/homeHrefs"
|
import { homeHrefs } from "@/constants/homeHrefs"
|
||||||
import { env } from "@/env/server"
|
import { env } from "@/env/server"
|
||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
|
||||||
import { BookingWidget } from "@/components/BookingWidget"
|
|
||||||
import { getLang } from "@/i18n/serverContext"
|
import { getLang } from "@/i18n/serverContext"
|
||||||
|
|
||||||
import { MainMenu } from "./MainMenu"
|
import { MainMenu } from "./MainMenu"
|
||||||
@@ -24,12 +22,6 @@ export default async function Header({
|
|||||||
|
|
||||||
const user = await serverClient().user.name()
|
const user = await serverClient().user.name()
|
||||||
|
|
||||||
// Get the booking widget show/hide status based on page specific settings
|
|
||||||
const bookingWidgetToggle =
|
|
||||||
await serverClient().contentstack.base.page_settings({
|
|
||||||
lang: getLang(),
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -61,9 +53,6 @@ export default async function Header({
|
|||||||
bookingHref={homeHref}
|
bookingHref={homeHref}
|
||||||
user={user}
|
user={user}
|
||||||
/>
|
/>
|
||||||
{bookingWidgetToggle && bookingWidgetToggle.hideBookingWidget ? null : (
|
|
||||||
<BookingWidget />
|
|
||||||
)}
|
|
||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user