* feat(SW-3516): Include partnerLoyaltyNumber on bookings - Added user context to BookingFlowProviders for user state management. - Updated booking input and output schemas to accommodate new user data. - Refactored booking mutation logic to include user-related information. - Improved type definitions for better TypeScript support across booking components. Approved-by: Anton Gunnarsson
41 lines
949 B
TypeScript
41 lines
949 B
TypeScript
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({
|
|
app: "partner-sas",
|
|
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)
|
|
}
|