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