fix(SW-2614): send language to API

We were missing the language param on some endpoints. We are still
missing it on some, but I left those without when we don't need it, e.g.
when only caring about the IDs in the response.
This commit is contained in:
Niclas Edenvin
2025-05-06 11:07:04 +02:00
committed by Michael Zetterberg
parent 35a2ae9dcc
commit e0fe5ff0d5
7 changed files with 47 additions and 12 deletions

View File

@@ -157,6 +157,7 @@ export const updateBookingInput = z.object({
countryCode: z.string().optional(),
})
.optional(),
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
})
// Query

View File

@@ -151,10 +151,13 @@ export const bookingMutationRouter = router({
.mutation(async function ({ ctx, input }) {
const accessToken = ctx.session?.token.access_token ?? ctx.serviceToken
const { confirmationNumber } = ctx
const { refId, ...body } = input
const { language, refId, ...body } = input
const addPackageCounter = createCounter("trpc.booking", "package.add")
const metricsAddPackage = addPackageCounter.init({ confirmationNumber })
const metricsAddPackage = addPackageCounter.init({
confirmationNumber,
language,
})
metricsAddPackage.start()
@@ -167,7 +170,8 @@ export const bookingMutationRouter = router({
{
headers,
body: body,
}
},
{ language }
)
if (!apiResponse.ok) {
@@ -192,11 +196,12 @@ export const bookingMutationRouter = router({
.mutation(async function ({ ctx, input }) {
const accessToken = ctx.session?.token.access_token ?? ctx.serviceToken
const { confirmationNumber } = ctx
const { refId, language, ...body } = input
const { language, refId, ...body } = input
const guaranteeBookingCounter = createCounter("trpc.booking", "guarantee")
const metricsGuaranteeBooking = guaranteeBookingCounter.init({
confirmationNumber,
language,
})
metricsGuaranteeBooking.start()
@@ -236,11 +241,12 @@ export const bookingMutationRouter = router({
.mutation(async function ({ ctx, input }) {
const accessToken = ctx.session?.token.access_token || ctx.serviceToken
const { confirmationNumber } = ctx
const { refId, ...body } = input
const { language, refId, ...body } = input
const updateBookingCounter = createCounter("trpc.booking", "update")
const metricsUpdateBooking = updateBookingCounter.init({
confirmationNumber,
language,
})
metricsUpdateBooking.start()
@@ -252,7 +258,8 @@ export const bookingMutationRouter = router({
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
},
{ language }
)
if (!apiResponse.ok) {

View File

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