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

@@ -34,6 +34,12 @@ export default async function SelectRatePage({
return notFound()
}
// If someone tries to update the url with
// a bookingCode also, then we need to remove it
if (isRedemption && searchParams.bookingCode) {
searchParams.bookingCode = ""
}
return (
<Suspense
key={suspenseKey}

View File

@@ -99,7 +99,7 @@ export default function useModifyStay({
bookingCode: bookedRoom.bookingCode ?? undefined,
rateCode: bookedRoom.rateDefinition.rateCode,
roomTypeCode: bookedRoom.roomTypeCode,
inputLang: lang,
lang,
})
if (!data?.selectedRoom || data.selectedRoom.roomsLeft <= 0) {

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)

View File

@@ -198,16 +198,16 @@ export const protectedServerActionProcedure = serverActionProcedure.use(
// NOTE: This is actually safe to use, just the implementation could change
// in minor version bumps. Please read: https://trpc.io/docs/faq#unstable
export const contentStackUidWithServiceProcedure =
contentstackExtendedProcedureUID.unstable_concat(serviceProcedure)
contentstackExtendedProcedureUID.concat(serviceProcedure)
export const contentStackBaseWithServiceProcedure =
contentstackBaseProcedure.unstable_concat(serviceProcedure)
contentstackBaseProcedure.concat(serviceProcedure)
export const contentStackBaseWithProtectedProcedure =
contentstackBaseProcedure.unstable_concat(protectedProcedure)
contentstackBaseProcedure.concat(protectedProcedure)
export const safeProtectedServiceProcedure =
safeProtectedProcedure.unstable_concat(serviceProcedure)
safeProtectedProcedure.concat(serviceProcedure)
export const languageProtectedProcedure =
protectedProcedure.unstable_concat(languageProcedure)
protectedProcedure.concat(languageProcedure)