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:
39
apps/partner-sas/lib/trpc/index.ts
Normal file
39
apps/partner-sas/lib/trpc/index.ts
Normal 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)
|
||||
}
|
||||
14
apps/partner-sas/lib/trpc/memoizedRequests/getHotel.ts
Normal file
14
apps/partner-sas/lib/trpc/memoizedRequests/getHotel.ts
Normal 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)
|
||||
})
|
||||
Reference in New Issue
Block a user