Merged in chore/upgrade-next (pull request #3124)
Upgrade next@15.5.6 * chore: upgrade next@15.5.6 * chore: upgrade turborepo@2.6.1 * fix typings for scandic-web * fix: set correct type for pages * cleanup * fix more route.ts typing issues * Merge branch 'master' of bitbucket.org:scandic-swap/web into chore/upgrade-next * explicitly import the types Approved-by: Linus Flood
This commit is contained in:
@@ -12,7 +12,7 @@ import { signOut } from "@/auth"
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ lang: Lang }> }
|
||||
context: RouteContext<"/[lang]/logout">
|
||||
) {
|
||||
const publicURL = getPublicURL(request)
|
||||
|
||||
@@ -71,6 +71,8 @@ export async function GET(
|
||||
case Lang.sv:
|
||||
redirectUrlValue = env.SEAMLESS_LOGOUT_SV
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported language for logout: ${params.lang}`)
|
||||
}
|
||||
const redirectUrl = new URL(redirectUrlValue)
|
||||
logger.debug(
|
||||
|
||||
@@ -3,9 +3,7 @@ import { Suspense } from "react"
|
||||
import Breadcrumbs from "@/components/Breadcrumbs"
|
||||
import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default function AllBreadcrumbs({}: PageArgs<LangParams>) {
|
||||
export default function AllBreadcrumbs() {
|
||||
return (
|
||||
<Suspense fallback={<BreadcrumbsSkeleton />}>
|
||||
<Breadcrumbs size="contentWidth" />
|
||||
|
||||
@@ -10,13 +10,9 @@ import { getIntl } from "@/i18n"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function MyPages({}: PageArgs<
|
||||
LangParams & { path: string[] }
|
||||
>) {
|
||||
export default async function MyPages() {
|
||||
const caller = await serverClient()
|
||||
const accountPageRes = await caller.contentstack.accountPage.get()
|
||||
const intl = await getIntl()
|
||||
|
||||
@@ -4,11 +4,9 @@ import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Profile from "@/components/MyPages/Profile"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function ProfilePage({}: PageArgs<LangParams>) {
|
||||
export default async function ProfilePage() {
|
||||
const caller = await serverClient()
|
||||
const accountPage = await caller.contentstack.accountPage.get()
|
||||
|
||||
|
||||
@@ -2,20 +2,19 @@ import { setPreviewData } from "@scandic-hotels/trpc/previewContext"
|
||||
|
||||
import InitLivePreview from "@/components/LivePreview"
|
||||
|
||||
import type { PageArgs } from "@/types/params"
|
||||
|
||||
export default async function PreviewPage(
|
||||
props: PageArgs<
|
||||
object,
|
||||
{ live_preview?: string; entry_uid?: string; isPreview?: string }
|
||||
>
|
||||
) {
|
||||
export default async function PreviewPage(props: PageProps<"/[lang]">) {
|
||||
const searchParams = await props.searchParams
|
||||
const hash = searchParams.live_preview
|
||||
const uid = searchParams.entry_uid
|
||||
const shouldInitializePreview = searchParams.isPreview === "true"
|
||||
|
||||
if (shouldInitializePreview && hash && uid) {
|
||||
if (
|
||||
shouldInitializePreview &&
|
||||
typeof hash === "string" &&
|
||||
hash &&
|
||||
typeof uid === "string" &&
|
||||
uid
|
||||
) {
|
||||
setPreviewData({ hash, uid })
|
||||
}
|
||||
|
||||
|
||||
@@ -5,20 +5,23 @@ import DestinationCityPageSkeleton from "@/components/ContentType/DestinationPag
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { PageArgs } from "@/types/params"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function DestinationCityPagePage(
|
||||
props: PageArgs<object, { view?: "map"; filterFromUrl?: string }>
|
||||
props: PageProps<"/[lang]/destination_city_page/[uid]">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<Suspense fallback={<DestinationCityPageSkeleton />}>
|
||||
<DestinationCityPage
|
||||
isMapView={searchParams.view === "map"}
|
||||
filterFromUrl={searchParams.filterFromUrl}
|
||||
filterFromUrl={
|
||||
typeof searchParams.filterFromUrl === "string"
|
||||
? searchParams.filterFromUrl
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
@@ -5,20 +5,22 @@ import DestinationCountryPageSkeleton from "@/components/ContentType/Destination
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { PageArgs } from "@/types/params"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function DestinationCountryPagePage(
|
||||
props: PageArgs<object, { view?: "map"; filterFromUrl?: string }>
|
||||
props: PageProps<"/[lang]/destination_country_page/[uid]">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<Suspense fallback={<DestinationCountryPageSkeleton />}>
|
||||
<DestinationCountryPage
|
||||
filterFromUrl={searchParams.filterFromUrl}
|
||||
isMapView={searchParams.view === "map"}
|
||||
filterFromUrl={
|
||||
typeof searchParams.filterFromUrl === "string"
|
||||
? searchParams.filterFromUrl
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
@@ -17,17 +17,21 @@ import HotelSubpage from "@/components/ContentType/HotelSubpage"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function HotelPagePage(
|
||||
props: PageArgs<LangParams, { subpage?: string; view?: "map" }>
|
||||
props: PageProps<"/[lang]/hotel_page/[uid]">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
const hotelPageData = await getHotelPage()
|
||||
|
||||
const subpage =
|
||||
typeof searchParams.subpage === "string" ? searchParams.subpage : null
|
||||
const lang = params.lang as Lang
|
||||
|
||||
if (!hotelPageData) {
|
||||
return notFound()
|
||||
}
|
||||
@@ -35,7 +39,7 @@ export default async function HotelPagePage(
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotelPageData.hotel_page_id,
|
||||
isCardOnlyPayment: false,
|
||||
language: params.lang,
|
||||
language: lang,
|
||||
})
|
||||
|
||||
if (!hotelData) {
|
||||
@@ -48,10 +52,10 @@ export default async function HotelPagePage(
|
||||
|
||||
setTheme(hotelTheme)
|
||||
|
||||
if (searchParams.subpage) {
|
||||
if (subpage) {
|
||||
return (
|
||||
<HotelPageWrapper hotelTheme={hotelTheme}>
|
||||
<HotelSubpage hotelData={hotelData} subpage={searchParams.subpage} />
|
||||
<HotelSubpage hotelData={hotelData} subpage={subpage} />
|
||||
</HotelPageWrapper>
|
||||
)
|
||||
} else if (searchParams.view === "map") {
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||
import type { LayoutProps } from "@/.next/types/app/[lang]/(live)/(public)/(contentTypes)/layout"
|
||||
|
||||
export default function ContentTypeLayout({
|
||||
breadcrumbs,
|
||||
preview,
|
||||
children,
|
||||
}: React.PropsWithChildren<
|
||||
LayoutArgs<LangParams> & {
|
||||
breadcrumbs: React.ReactNode
|
||||
preview: React.ReactNode
|
||||
}
|
||||
>) {
|
||||
export default function ContentTypeLayout(props: LayoutProps) {
|
||||
return (
|
||||
<section className={styles.layout}>
|
||||
{preview}
|
||||
{breadcrumbs}
|
||||
{children}
|
||||
{props.preview}
|
||||
{props.breadcrumbs}
|
||||
{props.children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@ import StartPage from "@/components/ContentType/StartPage"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function StartPagePage(
|
||||
props: PageArgs<object, NextSearchParams>
|
||||
props: PageProps<"/[lang]/start_page/[uid]">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const booking = parseBookingWidgetSearchParams(searchParams)
|
||||
|
||||
@@ -5,10 +5,8 @@ import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function BookingConfirmationPage(
|
||||
props: PageArgs<LangParams, { RefId?: string }>
|
||||
props: PageProps<"/[lang]/hotelreservation/booking-confirmation">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const lang = await getLang()
|
||||
|
||||
@@ -5,28 +5,25 @@ import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import GuaranteeCallbackPage from "@/components/GuaranteeCallback"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { PaymentCallbackStatusEnum } from "@scandic-hotels/common/constants/paymentCallbackStatusEnum"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function GuaranteePaymentCallbackPage(
|
||||
props: PageArgs<
|
||||
LangParams,
|
||||
{
|
||||
status?: PaymentCallbackStatusEnum
|
||||
RefId?: string
|
||||
confirmationNumber?: string
|
||||
ancillary?: string
|
||||
}
|
||||
>
|
||||
props: PageProps<"/[lang]/hotelreservation/gla-payment-callback">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
logger.debug(`[gla-payment-callback] callback started`)
|
||||
const lang = params.lang
|
||||
const status = searchParams.status
|
||||
const confirmationNumber = searchParams.confirmationNumber
|
||||
const refId = searchParams.RefId
|
||||
const lang = params.lang as Lang
|
||||
const status = searchParams.status as PaymentCallbackStatusEnum
|
||||
const confirmationNumber =
|
||||
typeof searchParams.confirmationNumber === "string"
|
||||
? searchParams.confirmationNumber
|
||||
: null
|
||||
|
||||
const refId =
|
||||
typeof searchParams.RefId === "string" ? searchParams.RefId : null
|
||||
|
||||
if (!status || !confirmationNumber || !refId) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||
|
||||
export default function PaymentCallbackLayout({
|
||||
children,
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||
}: LayoutProps<"/[lang]/hotelreservation/payment-callback">) {
|
||||
return <div className={styles.layout}>{children}</div>
|
||||
}
|
||||
|
||||
@@ -6,23 +6,16 @@ import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { PaymentCallbackStatusEnum } from "@scandic-hotels/common/constants/paymentCallbackStatusEnum"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function PaymentCallbackPage(
|
||||
props: PageArgs<
|
||||
LangParams,
|
||||
{
|
||||
status?: PaymentCallbackStatusEnum
|
||||
confirmationNumber?: string
|
||||
}
|
||||
>
|
||||
props: PageProps<"/[lang]/hotelreservation/payment-callback">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
logger.debug(`[payment-callback] callback started`)
|
||||
const lang = params.lang
|
||||
const lang = params.lang as Lang
|
||||
|
||||
let userAccessToken = null
|
||||
const session = await auth()
|
||||
|
||||
@@ -4,22 +4,20 @@ import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
import { getHotel } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
params,
|
||||
}: PageArgs<LangParams, { hotel: string }>): Promise<Metadata> {
|
||||
}: PageProps<"/[lang]/hotelreservation/alternative-hotels/map">): Promise<Metadata> {
|
||||
const intl = await getIntl()
|
||||
|
||||
const { hotel } = await searchParams
|
||||
const { lang } = await params
|
||||
const lang = (await params).lang as Lang
|
||||
|
||||
if (!hotel || Array.isArray(hotel)) {
|
||||
return {}
|
||||
@@ -50,10 +48,11 @@ export async function generateMetadata({
|
||||
}
|
||||
|
||||
export default async function AlternativeHotelsMapPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
props: PageProps<"/[lang]/hotelreservation/alternative-hotels/map">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const lang = await getLang()
|
||||
const params = await props.params
|
||||
const lang = params.lang as Lang
|
||||
|
||||
return (
|
||||
<div className={styles.main}>
|
||||
|
||||
@@ -4,24 +4,19 @@ import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
import { getHotel } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import {
|
||||
type LangParams,
|
||||
type NextSearchParams,
|
||||
type PageArgs,
|
||||
} from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
params,
|
||||
}: PageArgs<LangParams, { hotel: string }>): Promise<Metadata> {
|
||||
export async function generateMetadata(
|
||||
props: PageProps<"/[lang]/hotelreservation/alternative-hotels">
|
||||
): Promise<Metadata> {
|
||||
const intl = await getIntl()
|
||||
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
|
||||
const { hotel } = await searchParams
|
||||
const { lang } = await params
|
||||
|
||||
if (!hotel || Array.isArray(hotel)) {
|
||||
return {}
|
||||
@@ -29,7 +24,7 @@ export async function generateMetadata({
|
||||
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotel,
|
||||
language: lang,
|
||||
language: params.lang as Lang,
|
||||
isCardOnlyPayment: false,
|
||||
})
|
||||
const hotelName = hotelData?.additionalData?.name
|
||||
@@ -52,10 +47,11 @@ export async function generateMetadata({
|
||||
}
|
||||
|
||||
export default async function AlternativeHotelsPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
props: PageProps<"/[lang]/hotelreservation/alternative-hotels">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const lang = await getLang()
|
||||
const lang = (await props.params).lang as Lang
|
||||
|
||||
return (
|
||||
<AlternativeHotelsPagePrimitive
|
||||
lang={lang}
|
||||
|
||||
@@ -2,17 +2,17 @@ import { EnterDetailsPage as EnterDetailsPagePrimitive } from "@scandic-hotels/b
|
||||
|
||||
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export default async function DetailsPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
props: PageProps<"/[lang]/hotelreservation/details">
|
||||
) {
|
||||
const { lang } = await props.params
|
||||
const params = await props.params
|
||||
const searchParams = await props.searchParams
|
||||
|
||||
return (
|
||||
<EnterDetailsPagePrimitive
|
||||
lang={lang}
|
||||
lang={params.lang as Lang}
|
||||
searchParams={searchParams}
|
||||
config={bookingFlowConfig}
|
||||
/>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||
|
||||
export default function StandardHotelReservationLayout({
|
||||
children,
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||
}: LayoutProps<"/[lang]/hotelreservation">) {
|
||||
return <div className={styles.layout}>{children}</div>
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import {
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export default async function HotelReservationPage(
|
||||
props: PageArgs<LangParams>
|
||||
props: PageProps<"/[lang]/hotelreservation">
|
||||
) {
|
||||
const params = await props.params
|
||||
|
||||
const pageTrackingData: TrackingSDKPageData = {
|
||||
pageId: "hotelreservation",
|
||||
domainLanguage: params.lang,
|
||||
domainLanguage: params.lang as Lang,
|
||||
channel: TrackingChannelEnum["hotelreservation"],
|
||||
pageName: "hotelreservation",
|
||||
siteSections: "hotelreservation",
|
||||
|
||||
@@ -3,34 +3,31 @@ import { toCapitalCase } from "@scandic-hotels/common/utils/toCapitalCase"
|
||||
|
||||
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, { city: string }>): Promise<Metadata> {
|
||||
const { city } = await searchParams
|
||||
export async function generateMetadata(
|
||||
props: PageProps<"/[lang]/hotelreservation/select-hotel/map">
|
||||
): Promise<Metadata> {
|
||||
const { city } = await props.searchParams
|
||||
|
||||
return {
|
||||
title: `${toCapitalCase(city)}`,
|
||||
title: `${toCapitalCase(typeof city === "string" ? city : "")}`,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SelectHotelMapPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
props: PageProps<"/[lang]/hotelreservation/select-hotel/map">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const lang = await getLang()
|
||||
const params = await props.params
|
||||
|
||||
return (
|
||||
<div className={styles.main}>
|
||||
<SelectHotelMapPagePrimitive
|
||||
lang={lang}
|
||||
lang={params.lang as Lang}
|
||||
searchParams={searchParams}
|
||||
config={bookingFlowConfig}
|
||||
/>
|
||||
|
||||
@@ -3,27 +3,29 @@ import { toCapitalCase } from "@scandic-hotels/common/utils/toCapitalCase"
|
||||
|
||||
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
export async function generateMetadata(
|
||||
props: PageProps<"/[lang]/hotelreservation/select-hotel">
|
||||
): Promise<Metadata> {
|
||||
const searchParams = await props.searchParams
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, { city: string }>): Promise<Metadata> {
|
||||
const { city } = await searchParams
|
||||
if (typeof searchParams.city !== "string" || !searchParams.city) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return {
|
||||
title: `${toCapitalCase(city)}`,
|
||||
title: `${toCapitalCase(searchParams.city)}`,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SelectHotelPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
props: PageProps<"/[lang]/hotelreservation/select-hotel">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const lang = await getLang()
|
||||
const params = await props.params
|
||||
const lang = params.lang as Lang
|
||||
|
||||
return (
|
||||
<SelectHotelPagePrimitive
|
||||
|
||||
@@ -3,26 +3,22 @@ import { SelectRatePage as SelectRatePagePrimitive } from "@scandic-hotels/booki
|
||||
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
import { getHotel } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import {
|
||||
type LangParams,
|
||||
type NextSearchParams,
|
||||
type PageArgs,
|
||||
} from "@/types/params"
|
||||
export async function generateMetadata(
|
||||
props: PageProps<"/[lang]/hotelreservation/select-rate">
|
||||
): Promise<Metadata> {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
params,
|
||||
}: PageArgs<LangParams, { hotel: string }>): Promise<Metadata> {
|
||||
const { hotel } = await searchParams
|
||||
const { lang } = await params
|
||||
if (typeof searchParams.hotel !== "string" || !searchParams.hotel) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotel,
|
||||
language: lang,
|
||||
hotelId: searchParams.hotel,
|
||||
language: params.lang as Lang,
|
||||
isCardOnlyPayment: false,
|
||||
})
|
||||
|
||||
@@ -36,10 +32,12 @@ export async function generateMetadata({
|
||||
}
|
||||
|
||||
export default async function SelectRatePage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
props: PageProps<"/[lang]/hotelreservation/select-rate">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const lang = await getLang()
|
||||
const params = await props.params
|
||||
|
||||
const lang = params.lang as Lang
|
||||
|
||||
return (
|
||||
<SelectRatePagePrimitive
|
||||
|
||||
@@ -3,19 +3,21 @@ import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import Tracking from "./tracking"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export default async function MyStayPage(
|
||||
props: PageArgs<LangParams, { RefId?: string }>
|
||||
props: PageProps<"/[lang]/hotelreservation/my-stay">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
setLang(params.lang)
|
||||
const refId = searchParams.RefId
|
||||
const lang = params.lang as Lang
|
||||
setLang(lang)
|
||||
|
||||
const refId = typeof searchParams.RefId === "string" ? searchParams.RefId : ""
|
||||
|
||||
return (
|
||||
<>
|
||||
<MyStay refId={refId} lang={params.lang} />
|
||||
<MyStay refId={refId} lang={lang} />
|
||||
<Tracking />
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ import { signIn } from "@/auth"
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ lang: Lang }> }
|
||||
context: RouteContext<"/[lang]/login">
|
||||
) {
|
||||
const contextParams = await context.params
|
||||
const publicURL = getPublicURL(request)
|
||||
@@ -89,6 +89,10 @@ export async function GET(
|
||||
case Lang.sv:
|
||||
redirectUrlValue = env.SEAMLESS_LOGIN_SV
|
||||
break
|
||||
default:
|
||||
throw new Error(
|
||||
`Unsupported language for login: ${contextParams.lang}`
|
||||
)
|
||||
}
|
||||
const redirectUrl = new URL(redirectUrlValue)
|
||||
logger.debug(
|
||||
|
||||
@@ -8,11 +8,9 @@ import { getPublicURL } from "@/server/utils"
|
||||
|
||||
import { signIn } from "@/auth"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ lang: Lang }> }
|
||||
context: RouteContext<"/[lang]/verifymagiclink">
|
||||
) {
|
||||
const publicURL = getPublicURL(request)
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ import { getDestinationCityPage } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function BookingWidgetDestinationCityPage(
|
||||
props: PageArgs<object, NextSearchParams>
|
||||
props: PageProps<"/[lang]/destination_city_page/[uid]">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
|
||||
|
||||
@@ -4,17 +4,16 @@ import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/uti
|
||||
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
import { getHotel, getHotelPage } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { NextSearchParams, PageArgs } from "@/types/params"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export default async function BookingWidgetHotelPage(
|
||||
props: PageArgs<object, NextSearchParams & { subpage?: string }>
|
||||
props: PageProps<"/[lang]/hotel_page/[uid]">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
const lang = params.lang as Lang
|
||||
|
||||
const hotelPageData = await getHotelPage()
|
||||
const lang = await getLang()
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotelPageData?.hotel_page_id || "",
|
||||
language: lang,
|
||||
|
||||
@@ -3,18 +3,17 @@ import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/uti
|
||||
|
||||
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export default async function BookingWidgetPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
props: PageProps<"/[lang]/hotelreservation">
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
|
||||
const booking = parseBookingWidgetSearchParams(searchParams)
|
||||
|
||||
const lang = await getLang()
|
||||
const lang = params.lang as Lang
|
||||
|
||||
return (
|
||||
<BookingWidget booking={booking} lang={lang} config={bookingFlowConfig} />
|
||||
|
||||
@@ -3,18 +3,15 @@ import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/uti
|
||||
|
||||
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function BookingWidgetPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
) {
|
||||
export default async function BookingWidgetPage(props: PageProps<"/[lang]">) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
|
||||
const booking = parseBookingWidgetSearchParams(searchParams)
|
||||
|
||||
const lang = await getLang()
|
||||
const lang = params.lang as Lang
|
||||
|
||||
return (
|
||||
<BookingWidget booking={booking} lang={lang} config={bookingFlowConfig} />
|
||||
|
||||
@@ -35,21 +35,13 @@ import { getMessages } from "@/i18n"
|
||||
import ClientIntlProvider from "@/i18n/Provider"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||
|
||||
export default async function RootLayout(
|
||||
props: React.PropsWithChildren<
|
||||
LayoutArgs<LangParams> & {
|
||||
bookingwidget: React.ReactNode
|
||||
}
|
||||
>
|
||||
) {
|
||||
export default async function RootLayout(props: LayoutProps<"/[lang]">) {
|
||||
const params = await props.params
|
||||
|
||||
const lang = params.lang as Lang
|
||||
const { bookingwidget, children } = props
|
||||
|
||||
setLang(params.lang)
|
||||
const messages = await getMessages(params.lang)
|
||||
setLang(lang)
|
||||
const messages = await getMessages(lang)
|
||||
|
||||
return (
|
||||
<html lang={params.lang}>
|
||||
@@ -69,7 +61,7 @@ export default async function RootLayout(
|
||||
<SessionProvider basePath="/api/web/auth">
|
||||
<ClientIntlProvider
|
||||
defaultLocale={Lang.en}
|
||||
locale={params.lang}
|
||||
locale={lang}
|
||||
messages={messages}
|
||||
>
|
||||
<NuqsAdapter>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import NotFound from "@/components/NotFound"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default function NotFoundPage({}: PageArgs<LangParams>) {
|
||||
export default function NotFoundPage(
|
||||
_props: PageProps<"/[lang]/middleware-error/404">
|
||||
) {
|
||||
return <NotFound />
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { LangParams, LayoutArgs, StatusParams } from "@/types/params"
|
||||
|
||||
export default async function MiddlewareError(
|
||||
props: LayoutArgs<LangParams & StatusParams>
|
||||
props: PageProps<"/[lang]/middleware-error/[status]">
|
||||
) {
|
||||
const params = await props.params
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user