fix: unbreak toApiLang call that failed everytime

This commit is contained in:
Simon Emanuelsson
2025-04-03 09:16:15 +02:00
committed by Michael Zetterberg
parent 30c7eb07fa
commit 6d869ceba7
7 changed files with 23 additions and 20 deletions

View File

@@ -483,20 +483,18 @@ export const bookingMutationRouter = router({
update: safeProtectedServiceProcedure
.input(updateBookingInput)
.mutation(async function ({ ctx, input }) {
const accessToken = ctx.serviceToken
const accessToken = ctx.session?.token.access_token || ctx.serviceToken
const { confirmationNumber, ...body } = input
updateBookingCounter.add(1, { confirmationNumber })
const headers = {
Authorization: `Bearer ${accessToken}`,
}
const apiResponse = await api.put(
api.endpoints.v1.Booking.booking(confirmationNumber),
{
headers,
body: body,
body,
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
)

View File

@@ -61,7 +61,7 @@ export const selectedRoomAvailabilityInputSchema = z.object({
roomTypeCode: z.string(),
counterRateCode: z.string().optional(),
packageCodes: z.array(z.nativeEnum(RoomPackageCodeEnum)).optional(),
inputLang: z.nativeEnum(Lang).optional(),
lang: z.nativeEnum(Lang).optional(),
redemption: z.boolean().optional(),
})

View File

@@ -705,9 +705,10 @@ export const hotelQueryRouter = router({
})
})
.query(async ({ input, ctx }) => {
const lang = toApiLang(input.lang || ctx.lang)
let selectedRoomData = await getSelectedRoomAvailability(
input,
toApiLang(ctx.lang),
lang,
ctx.token,
ctx.userPoints
)
@@ -718,7 +719,6 @@ export const hotelQueryRouter = router({
children,
counterRateCode,
hotelId,
inputLang,
roomStayEndDate,
roomStayStartDate,
roomTypeCode,
@@ -797,7 +797,7 @@ export const hotelQueryRouter = router({
{
hotelId,
isCardOnlyPayment: false,
language: inputLang ?? ctx.lang,
language: input.lang || ctx.lang,
},
ctx.serviceToken
)
@@ -884,7 +884,7 @@ export const hotelQueryRouter = router({
adults,
...(children && { children }),
...(bookingCode && { bookingCode }),
language: inputLang ?? ctx.lang,
language: lang,
},
},
})

View File

@@ -618,7 +618,6 @@ export async function getSelectedRoomAvailability(
bookingCode,
children,
hotelId,
inputLang,
roomStayEndDate,
roomStayStartDate,
redemption,
@@ -631,7 +630,7 @@ export async function getSelectedRoomAvailability(
...(children && { children }),
...(bookingCode && { bookingCode }),
...(redemption && { isRedemption: "true" }),
language: inputLang ?? lang,
language: lang,
}
metrics.selectedRoomAvailability.counter.add(1, input)