Merged in SW-3490-set-metadata-for-routes (pull request #2881)

SW-3490 set metadata for routes
* feat(SW-3490): Set metadata title for hotelreservation paths

Approved-by: Anton Gunnarsson
This commit is contained in:
Joakim Jäderberg
2025-10-01 11:34:52 +00:00
parent 4f151b143e
commit df8e223d23
25 changed files with 440 additions and 37 deletions

View File

@@ -0,0 +1,39 @@
import { headers } from "next/headers"
import { createContext } from "@scandic-hotels/trpc/context"
import {
appServerClient,
configureServerClient,
} from "@scandic-hotels/trpc/serverClient"
import { auth } from "@/auth"
import type { Lang } from "@scandic-hotels/common/constants/language"
export async function createAppContext() {
const headersList = await headers()
const ctx = createContext({
lang: headersList.get("x-lang") as Lang,
pathname: headersList.get("x-pathname")!,
uid: headersList.get("x-uid"),
url: headersList.get("x-url")!,
contentType: headersList.get("x-contenttype")!,
auth: async () => {
const session = await auth()
return session
},
})
return ctx
}
export function configureTrpc() {
configureServerClient(createAppContext)
}
export async function serverClient() {
const ctx = await createAppContext()
return appServerClient(ctx)
}

View File

@@ -0,0 +1,14 @@
import { cache } from "react"
import { serverClient } from ".."
import type { HotelInput } from "@scandic-hotels/trpc/types/hotel"
export const getHotel = cache(async function getMemoizedHotelData(
input: HotelInput
) {
input.isCardOnlyPayment ??= false
const caller = await serverClient()
return caller.hotel.get(input)
})