Merged in fix/SW-3199-prod-users-are-displayed-with- (pull request #2592)

fix(SW-3199): Fixed redemption search for alternative hotels

* fix(SW-3199): Fixed redemption search for alternative hotels

* fix(SW-3199): User points validation included


Approved-by: Anton Gunnarsson
This commit is contained in:
Hrishikesh Vaipurkar
2025-08-07 07:29:32 +00:00
parent 9f4e2b3c45
commit 271d5ec32c
3 changed files with 46 additions and 5 deletions

View File

@@ -136,12 +136,40 @@ export const hotelQueryRouter = router({
env.CACHE_TIME_CITY_SEARCH
)
}),
hotelsByHotelIds: serviceProcedure
hotelsByHotelIds: safeProtectedServiceProcedure
.input(getHotelsByHotelIdsAvailabilityInputSchema)
.use(async ({ ctx, input, next }) => {
if (input.redemption) {
if (ctx.session?.token.access_token) {
const verifiedUser = await getVerifiedUser({ session: ctx.session })
if (!verifiedUser?.error) {
return next({
ctx: {
token: ctx.session.token.access_token,
userPoints: verifiedUser?.data.membership?.currentPoints ?? 0,
},
input,
})
}
}
throw unauthorizedError()
}
return next({
ctx: {
token: ctx.serviceToken,
},
input,
})
})
.query(async ({ input, ctx }) => {
const { lang } = ctx
const apiLang = toApiLang(lang)
return getHotelsAvailabilityByHotelIds(input, apiLang, ctx.serviceToken)
return getHotelsAvailabilityByHotelIds(
input,
apiLang,
ctx.token,
ctx.userPoints
)
}),
enterDetails: safeProtectedServiceProcedure