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

@@ -7,7 +7,8 @@ import { env } from "../../../../env/server"
import { unauthorizedError } from "../../../errors"
import { safeProtectedServiceProcedure } from "../../../procedures"
import { toApiLang } from "../../../utils"
import { getVerifiedUser } from "../../user/utils/getVerifiedUser"
import { getRedemptionTokenSafely } from "../../../utils/getRedemptionTokenSafely"
import { getUserPointsBalance } from "../../../utils/getUserPointsBalance"
import { getHotelsAvailabilityByCity } from "../services/getHotelsAvailabilityByCity"
export type HotelsAvailabilityInputSchema = z.output<
@@ -68,12 +69,13 @@ export const hotelsByCity = safeProtectedServiceProcedure
.use(async ({ ctx, input, next }) => {
if (input.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,
})