Merged in fix/sw-3495-booking-flow-links-to-web (pull request #2837)

fix: (SW-3495): Update booking-flow links in partner-sas

* Update links to scandic web in booking-flow

* Fix routeToScandicWeb util function


Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
Anton Gunnarsson
2025-09-22 13:30:38 +00:00
parent 630e89c845
commit c21d0dbc74
9 changed files with 70 additions and 23 deletions

View File

@@ -11,6 +11,10 @@ import { SessionProvider } from "next-auth/react"
import { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlowConfig"
import { NuqsAdapter } from "@scandic-hotels/booking-flow/utils/nuqs"
import { Lang } from "@scandic-hotels/common/constants/language"
import { bookingTermsAndConditionsRoutes } from "@scandic-hotels/common/constants/routes/bookingTermsAndConditionsRoutes"
import { customerService } from "@scandic-hotels/common/constants/routes/customerService"
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
import { privacyPolicyRoutes } from "@scandic-hotels/common/constants/routes/privacyPolicyRoutes"
import { ToastHandler } from "@scandic-hotels/design-system/ToastHandler"
import AdobeSDKScript from "@/components/AdobeSDKScript"
@@ -28,11 +32,12 @@ import { BookingFlowProviders } from "../../components/BookingFlowProviders"
import { Footer } from "../../components/Footer/Footer"
import { Header } from "../../components/Header/Header"
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
import type { Metadata } from "next"
export const metadata: Metadata = {
title: "SAS by Scandic Hotels",
description: "This text should be updated.",
description: "TODO This text should be updated.",
}
type LangParams = {
@@ -45,8 +50,6 @@ type RootLayoutProps = {
bookingwidget: React.ReactNode
}
const bookingFlowConfig = { bookingCodeEnabled: false } as const
export default async function RootLayout(props: RootLayoutProps) {
const params = await props.params
const lang = params.lang
@@ -56,6 +59,18 @@ export default async function RootLayout(props: RootLayoutProps) {
const parsedLanguage = setLang(lang)
const messages = await getMessages(parsedLanguage)
const bookingFlowConfig: BookingFlowConfig = {
bookingCodeEnabled: false,
routes: {
myStay: routeToScandicWeb(myStay),
bookingTermsAndConditions: routeToScandicWeb(
bookingTermsAndConditionsRoutes
),
customerService: routeToScandicWeb(customerService),
privacyPolicy: routeToScandicWeb(privacyPolicyRoutes),
},
}
return (
<html lang="en">
<head>
@@ -112,3 +127,11 @@ export default async function RootLayout(props: RootLayoutProps) {
</html>
)
}
function routeToScandicWeb(route: LangRoute) {
const url = `https://www.scandichotels.com`
return Object.entries(route).reduce((acc, [key, value]) => {
acc[key as Lang] = `${url}/${value}`
return acc
}, {} as LangRoute)
}

View File

@@ -1 +1,16 @@
export const bookingFlowConfig = { bookingCodeEnabled: true } as const
import { bookingTermsAndConditionsRoutes } from "@scandic-hotels/common/constants/routes/bookingTermsAndConditionsRoutes"
import { customerService } from "@scandic-hotels/common/constants/routes/customerService"
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
import { privacyPolicyRoutes } from "@scandic-hotels/common/constants/routes/privacyPolicyRoutes"
import type { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlowConfig"
export const bookingFlowConfig: BookingFlowConfig = {
bookingCodeEnabled: true,
routes: {
myStay,
customerService,
bookingTermsAndConditions: bookingTermsAndConditionsRoutes,
privacyPolicy: privacyPolicyRoutes,
},
}

View File

@@ -4,8 +4,16 @@ import { cache } from "react"
import { BookingFlowConfigContextProvider } from "./bookingFlowConfigContext"
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
export type BookingFlowConfig = {
bookingCodeEnabled: boolean
routes: {
myStay: LangRoute
bookingTermsAndConditions: LangRoute
customerService: LangRoute
privacyPolicy: LangRoute
}
}
const getRef = cache(() => ({

View File

@@ -4,9 +4,7 @@ import { createContext, useContext } from "react"
import type { BookingFlowConfig } from "./bookingFlowConfig"
type BookingFlowConfigContextData = {
config: BookingFlowConfig
}
type BookingFlowConfigContextData = BookingFlowConfig
const BookingFlowConfigContext = createContext<
BookingFlowConfigContextData | undefined
@@ -32,7 +30,7 @@ export function BookingFlowConfigContextProvider({
config: BookingFlowConfig
}) {
return (
<BookingFlowConfigContext.Provider value={{ config }}>
<BookingFlowConfigContext.Provider value={config}>
{children}
</BookingFlowConfigContext.Provider>
)

View File

@@ -3,10 +3,10 @@
import { useEffect } from "react"
import { useIntl } from "react-intl"
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
import ButtonLink from "@scandic-hotels/design-system/ButtonLink"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
import useLang from "../../../../hooks/useLang"
import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation"
@@ -18,6 +18,7 @@ type ManageBookingProps = Pick<BookingConfirmation, "booking">
export default function ManageBooking({ booking }: ManageBookingProps) {
const intl = useIntl()
const lang = useLang()
const { routes } = useBookingFlowConfig()
const { refId, confirmationNumber } = booking
const { email, firstName, lastName } = booking.guest
@@ -32,7 +33,7 @@ export default function ManageBooking({ booking }: ManageBookingProps) {
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
}, [confirmationNumber, email, firstName, lastName])
const myStayURL = `${myStay[lang]}?RefId=${encodeURIComponent(refId)}`
const myStayURL = `${routes.myStay[lang]}?RefId=${encodeURIComponent(refId)}`
return (
<ButtonLink

View File

@@ -2,8 +2,7 @@
import { useEffect } from "react"
import { useIntl } from "react-intl"
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
import { useBookingFlowConfig } from "../../../bookingFlowConfig/bookingFlowConfigContext"
import useLang from "../../../hooks/useLang"
import { Promo } from "./Promo"
@@ -18,6 +17,8 @@ type PromosProps = Pick<BookingConfirmation, "booking">
export function Promos({ booking }: PromosProps) {
const intl = useIntl()
const lang = useLang()
const { routes } = useBookingFlowConfig()
const { refId, confirmationNumber, hotelId } = booking
const { email, firstName, lastName } = booking.guest
useEffect(() => {
@@ -31,7 +32,7 @@ export function Promos({ booking }: PromosProps) {
document.cookie = `bv=${JSON.stringify(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
}, [confirmationNumber, email, firstName, lastName])
const myStayURL = `${myStay[lang]}?RefId=${encodeURIComponent(refId)}`
const myStayURL = `${routes.myStay[lang]}?RefId=${encodeURIComponent(refId)}`
return (
<div className={styles.promos}>
<Promo

View File

@@ -12,7 +12,7 @@ import RewardNight from "../RewardNight"
import styles from "./voucher.module.css"
export default function Voucher() {
const { config } = useBookingFlowConfig()
const config = useBookingFlowConfig()
return (
<div className={styles.optionsContainer}>
@@ -28,7 +28,7 @@ export default function Voucher() {
export function VoucherSkeleton() {
const intl = useIntl()
const { config } = useBookingFlowConfig()
const config = useBookingFlowConfig()
const vouchers = intl.formatMessage({
defaultMessage: "Code / Voucher",

View File

@@ -2,12 +2,12 @@
import { useIntl } from "react-intl"
import { customerService } from "@scandic-hotels/common/constants/routes/customerService"
import Body from "@scandic-hotels/design-system/Body"
import Link from "@scandic-hotels/design-system/Link"
import { LoadingSpinner } from "@scandic-hotels/design-system/LoadingSpinner"
import Subtitle from "@scandic-hotels/design-system/Subtitle"
import { useBookingFlowConfig } from "../../../../../bookingFlowConfig/bookingFlowConfigContext"
import useLang from "../../../../../hooks/useLang"
import styles from "./timeoutSpinner.module.css"
@@ -15,6 +15,7 @@ import styles from "./timeoutSpinner.module.css"
export default function TimeoutSpinner() {
const intl = useIntl()
const lang = useLang()
const { routes } = useBookingFlowConfig()
return (
<div className={styles.container}>
@@ -33,7 +34,7 @@ export default function TimeoutSpinner() {
{
link: (text) => (
<Link
href={customerService[lang]}
href={routes.customerService[lang]}
textDecoration="underline"
target="_blank"
>

View File

@@ -1,12 +1,11 @@
import { useIntl } from "react-intl"
import { bookingTermsAndConditionsRoutes } from "@scandic-hotels/common/constants/routes/bookingTermsAndConditionsRoutes"
import { privacyPolicyRoutes } from "@scandic-hotels/common/constants/routes/privacyPolicyRoutes"
import Caption from "@scandic-hotels/design-system/Caption"
import Checkbox from "@scandic-hotels/design-system/Form/Checkbox"
import Link from "@scandic-hotels/design-system/Link"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
import useLang from "../../../../hooks/useLang"
import { paymentError } from "../schema"
@@ -20,6 +19,7 @@ export default function TermsAndConditions({
}: TermsAndConditionsProps) {
const intl = useIntl()
const lang = useLang()
const { routes } = useBookingFlowConfig()
return (
<>
@@ -35,7 +35,7 @@ export default function TermsAndConditions({
<Link
className={styles.link}
textDecoration="underline"
href={bookingTermsAndConditionsRoutes[lang]}
href={routes.bookingTermsAndConditions[lang]}
target="_blank"
weight="bold"
size="small"
@@ -47,7 +47,7 @@ export default function TermsAndConditions({
<Link
className={styles.link}
textDecoration="underline"
href={privacyPolicyRoutes[lang]}
href={routes.privacyPolicy[lang]}
target="_blank"
weight="bold"
size="small"
@@ -67,7 +67,7 @@ export default function TermsAndConditions({
<Link
className={styles.link}
textDecoration="underline"
href={bookingTermsAndConditionsRoutes[lang]}
href={routes.bookingTermsAndConditions[lang]}
target="_blank"
weight="bold"
size="small"
@@ -79,7 +79,7 @@ export default function TermsAndConditions({
<Link
className={styles.link}
textDecoration="underline"
href={privacyPolicyRoutes[lang]}
href={routes.privacyPolicy[lang]}
target="_blank"
weight="bold"
size="small"