feat(SW-2622): pass language to guarantee booking

This commit is contained in:
Michael Zetterberg
2025-05-06 13:53:13 +02:00
parent 1679e1d65d
commit b720a894fd
2 changed files with 14 additions and 2 deletions

View File

@@ -4,6 +4,8 @@ import { useRef } from "react"
import { trpc } from "@/lib/trpc/client"
import useLang from "@/hooks/useLang"
import type { BookingStatusEnum } from "@/constants/booking"
export function useHandleBookingStatus({
@@ -19,10 +21,14 @@ export function useHandleBookingStatus({
retryInterval: number
enabled: boolean
}) {
const lang = useLang()
const retries = useRef(0)
const query = trpc.booking.status.useQuery(
{ refId: refId ?? "" },
{
lang,
refId: refId ?? "",
},
{
enabled,
refetchInterval: (query) => {

View File

@@ -7,6 +7,7 @@ import {
safeProtectedServiceProcedure,
serviceProcedure,
} from "@/server/trpc"
import { toApiLang } from "@/server/utils"
import { getBookedHotelRoom } from "@/utils/booking"
@@ -207,8 +208,10 @@ export const bookingQueryRouter = router({
status: serviceProcedure
.input(getBookingStatusInput)
.concat(refIdPlugin.toConfirmationNumber)
.query(async function ({ ctx }) {
.query(async function ({ ctx, input }) {
const lang = input.lang ?? ctx.lang
const { confirmationNumber } = ctx
const language = toApiLang(lang)
const getBookingStatusCounter = createCounter("trpc.booking", "status")
const metricsGetBookingStatus = getBookingStatusCounter.init({
@@ -223,6 +226,9 @@ export const bookingQueryRouter = router({
headers: {
Authorization: `Bearer ${ctx.serviceToken}`,
},
},
{
language,
}
)