Merged in chore/move-enter-details (pull request #2778)
Chore/move enter details Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { cache } from "react"
|
||||
|
||||
import { serverClient } from "../../trpc"
|
||||
|
||||
import type { BreackfastPackagesInput } from "@scandic-hotels/trpc/types/packages"
|
||||
|
||||
export const getBreakfastPackages = cache(
|
||||
async function getMemoizedBreakfastPackages(input: BreackfastPackagesInput) {
|
||||
const caller = await serverClient()
|
||||
return caller.hotel.packages.breakfast(input)
|
||||
}
|
||||
)
|
||||
15
packages/booking-flow/lib/trpc/memoizedRequests/getHotel.ts
Normal file
15
packages/booking-flow/lib/trpc/memoizedRequests/getHotel.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { cache } from "react"
|
||||
|
||||
import { serverClient } from "../../trpc"
|
||||
|
||||
import type { HotelInput } from "@scandic-hotels/trpc/types/hotel"
|
||||
|
||||
export const getHotel = cache(async function getMemoizedHotelData(
|
||||
input: HotelInput
|
||||
) {
|
||||
if (!input.isCardOnlyPayment) {
|
||||
input.isCardOnlyPayment = false
|
||||
}
|
||||
const caller = await serverClient()
|
||||
return caller.hotel.get(input)
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { cache } from "react"
|
||||
|
||||
import { serverClient } from "../../trpc"
|
||||
|
||||
export const getProfileSafely = cache(
|
||||
async function getMemoizedProfileSafely() {
|
||||
const caller = await serverClient()
|
||||
return caller.user.getSafely()
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
import { cache } from "react"
|
||||
|
||||
import { serverClient } from "../../trpc"
|
||||
|
||||
import type { GetSavedPaymentCardsInput } from "@scandic-hotels/trpc/routers/user/input"
|
||||
|
||||
export const getSavedPaymentCardsSafely = cache(
|
||||
async function getMemoizedSavedPaymentCardsSafely(
|
||||
input: GetSavedPaymentCardsInput
|
||||
) {
|
||||
const caller = await serverClient()
|
||||
return caller.user.safePaymentCards(input)
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
import { redirect } from "next/navigation"
|
||||
import { cache } from "react"
|
||||
|
||||
import { serverClient } from "../../trpc"
|
||||
|
||||
import type { RoomsAvailabilityExtendedInputSchema } from "@scandic-hotels/trpc/types/availability"
|
||||
|
||||
export const getSelectedRoomsAvailabilityEnterDetails = cache(
|
||||
async function getMemoizedSelectedRoomsAvailability(
|
||||
input: RoomsAvailabilityExtendedInputSchema
|
||||
) {
|
||||
const caller = await serverClient()
|
||||
const result = await caller.hotel.availability.enterDetails(input)
|
||||
|
||||
if (typeof result === "string") {
|
||||
redirect(result)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user