fix: rename trpc route for get booking
This commit is contained in:
@@ -24,7 +24,7 @@ export function LinkedReservation({
|
||||
roomIndex,
|
||||
}: LinkedReservationProps) {
|
||||
const lang = useLang()
|
||||
const { data, refetch, isLoading } = trpc.booking.confirmation.useQuery({
|
||||
const { data, refetch, isLoading } = trpc.booking.get.useQuery({
|
||||
confirmationNumber,
|
||||
lang,
|
||||
})
|
||||
|
||||
@@ -179,7 +179,7 @@ export default function AddAncillaryFlowModal({
|
||||
)
|
||||
clearAncillarySessionData()
|
||||
closeModal()
|
||||
utils.booking.confirmation.invalidate({
|
||||
utils.booking.get.invalidate({
|
||||
confirmationNumber: booking.confirmationNumber,
|
||||
})
|
||||
router.refresh()
|
||||
|
||||
@@ -136,7 +136,7 @@ export const getPackages = cache(async function getMemoizedPackages(
|
||||
|
||||
export const getBookingConfirmation = cache(
|
||||
async function getMemoizedBookingConfirmation(confirmationNumber: string) {
|
||||
return serverClient().booking.confirmation({ confirmationNumber })
|
||||
return serverClient().booking.get({ confirmationNumber })
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -174,6 +174,6 @@ const confirmationNumberInput = z.object({
|
||||
lang: z.nativeEnum(Lang).optional(),
|
||||
})
|
||||
|
||||
export const bookingConfirmationInput = confirmationNumberInput
|
||||
export const getBookingInput = confirmationNumberInput
|
||||
|
||||
export const getBookingStatusInput = confirmationNumberInput
|
||||
|
||||
@@ -11,23 +11,17 @@ import {
|
||||
import { getHotel } from "../hotels/utils"
|
||||
import { encrypt } from "../utils/encryption"
|
||||
import {
|
||||
bookingConfirmationInput,
|
||||
createRefIdInput,
|
||||
getBookingInput,
|
||||
getBookingStatusInput,
|
||||
} from "./input"
|
||||
import { bookingConfirmationSchema, createBookingSchema } from "./output"
|
||||
import { getBookedHotelRoom } from "./utils"
|
||||
|
||||
const meter = metrics.getMeter("trpc.booking")
|
||||
const getBookingConfirmationCounter = meter.createCounter(
|
||||
"trpc.booking.confirmation"
|
||||
)
|
||||
const getBookingConfirmationSuccessCounter = meter.createCounter(
|
||||
"trpc.booking.confirmation-success"
|
||||
)
|
||||
const getBookingConfirmationFailCounter = meter.createCounter(
|
||||
"trpc.booking.confirmation-fail"
|
||||
)
|
||||
const getBookingCounter = meter.createCounter("trpc.booking.get")
|
||||
const getBookingSuccessCounter = meter.createCounter("trpc.booking.get-success")
|
||||
const getBookingFailCounter = meter.createCounter("trpc.booking.get-fail")
|
||||
|
||||
const getBookingStatusCounter = meter.createCounter("trpc.booking.status")
|
||||
const getBookingStatusSuccessCounter = meter.createCounter(
|
||||
@@ -38,13 +32,13 @@ const getBookingStatusFailCounter = meter.createCounter(
|
||||
)
|
||||
|
||||
export const bookingQueryRouter = router({
|
||||
confirmation: safeProtectedServiceProcedure
|
||||
.input(bookingConfirmationInput)
|
||||
get: safeProtectedServiceProcedure
|
||||
.input(getBookingInput)
|
||||
.query(async function ({
|
||||
ctx,
|
||||
input: { confirmationNumber, lang: inputLang },
|
||||
}) {
|
||||
getBookingConfirmationCounter.add(1, { confirmationNumber })
|
||||
getBookingCounter.add(1, { confirmationNumber })
|
||||
|
||||
let lang = ctx.lang ?? inputLang
|
||||
|
||||
@@ -61,7 +55,7 @@ export const bookingQueryRouter = router({
|
||||
|
||||
if (!apiResponse.ok) {
|
||||
const responseMessage = await apiResponse.text()
|
||||
getBookingConfirmationFailCounter.add(1, {
|
||||
getBookingFailCounter.add(1, {
|
||||
confirmationNumber,
|
||||
error_type: "http_error",
|
||||
error: responseMessage,
|
||||
@@ -90,7 +84,7 @@ export const bookingQueryRouter = router({
|
||||
const apiJson = await apiResponse.json()
|
||||
const booking = bookingConfirmationSchema.safeParse(apiJson)
|
||||
if (!booking.success) {
|
||||
getBookingConfirmationFailCounter.add(1, {
|
||||
getBookingFailCounter.add(1, {
|
||||
confirmationNumber,
|
||||
error_type: "validation_error",
|
||||
error: JSON.stringify(booking.error),
|
||||
@@ -115,7 +109,7 @@ export const bookingQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!hotelData) {
|
||||
getBookingConfirmationFailCounter.add(1, {
|
||||
getBookingFailCounter.add(1, {
|
||||
confirmationNumber,
|
||||
hotelId: booking.data.hotelId,
|
||||
error_type: "http_error",
|
||||
@@ -136,7 +130,7 @@ export const bookingQueryRouter = router({
|
||||
throw serverErrorByStatus(404)
|
||||
}
|
||||
|
||||
getBookingConfirmationSuccessCounter.add(1, { confirmationNumber })
|
||||
getBookingSuccessCounter.add(1, { confirmationNumber })
|
||||
console.info(
|
||||
"api.booking.confirmation success",
|
||||
JSON.stringify({
|
||||
|
||||
@@ -4,11 +4,9 @@ import type { RouterOutput } from "@/lib/trpc/client"
|
||||
|
||||
export interface AddToCalendarProps {
|
||||
checkInDate: NonNullable<
|
||||
RouterOutput["booking"]["confirmation"]
|
||||
RouterOutput["booking"]["get"]
|
||||
>["booking"]["checkInDate"]
|
||||
event: EventAttributes
|
||||
hotelName: NonNullable<
|
||||
RouterOutput["booking"]["confirmation"]
|
||||
>["hotel"]["name"]
|
||||
hotelName: NonNullable<RouterOutput["booking"]["get"]>["hotel"]["name"]
|
||||
renderButton: (onPress: () => Promise<void>) => React.ReactNode
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user