Merged in feat/SW-3526-show-sas-eb-points-rate-in- (pull request #2933)

feat(SW-3526): Show EB points rate and label in booking flow

* feat(SW-3526): Show EB points rate and label in booking flow

* feat(SW-3526) Optimized points currency code

* feat(SW-3526) Removed extra multiplication for token expiry after rebase

* feat(SW-3526): Updated to exhaustive check and thow if type error

Approved-by: Anton Gunnarsson
This commit is contained in:
Hrishikesh Vaipurkar
2025-10-15 06:54:44 +00:00
parent 73af1eed9b
commit 78ede453a2
27 changed files with 281 additions and 176 deletions

View File

@@ -9,7 +9,8 @@ import { SEARCH_TYPE_REDEMPTION } from "../../../constants/booking"
import { AvailabilityEnum } from "../../../enums/selectHotel"
import { unauthorizedError } from "../../../errors"
import { safeProtectedServiceProcedure } from "../../../procedures"
import { getVerifiedUser } from "../../user/utils/getVerifiedUser"
import { getRedemptionTokenSafely } from "../../../utils/getRedemptionTokenSafely"
import { getUserPointsBalance } from "../../../utils/getUserPointsBalance"
import { baseBookingSchema, baseRoomSchema, selectedRoomSchema } from "../input"
import { getHotel } from "../services/getHotel"
import { getRoomsAvailability } from "../services/getRoomsAvailability"
@@ -37,13 +38,15 @@ export const enterDetails = safeProtectedServiceProcedure
.use(async ({ ctx, input, next }) => {
if (input.booking.searchType === SEARCH_TYPE_REDEMPTION) {
if (ctx.session?.token.access_token) {
const verifiedUser = await getVerifiedUser({ session: ctx.session })
if (!verifiedUser?.error) {
const pointsValue = await getUserPointsBalance(ctx.session)
const token = getRedemptionTokenSafely(ctx.session, ctx.serviceToken)
if (pointsValue && token) {
return next({
ctx: {
token: ctx.session.token.access_token,
userPoints: verifiedUser?.data.membership?.currentPoints ?? 0,
token: token,
userPoints: pointsValue ?? 0,
},
input,
})
}
}