feat: SW-2028 Implemented validation for not enough points details page
This commit is contained in:
@@ -657,12 +657,16 @@ export const hotelQueryRouter = router({
|
|||||||
.use(async ({ ctx, input, next }) => {
|
.use(async ({ ctx, input, next }) => {
|
||||||
if (input.redemption) {
|
if (input.redemption) {
|
||||||
if (ctx.session?.token.access_token) {
|
if (ctx.session?.token.access_token) {
|
||||||
return next({
|
const verifiedUser = await getVerifiedUser({ session: ctx.session })
|
||||||
ctx: {
|
if (!verifiedUser?.error) {
|
||||||
token: ctx.session.token.access_token,
|
return next({
|
||||||
},
|
ctx: {
|
||||||
input,
|
token: ctx.session.token.access_token,
|
||||||
})
|
userPoints: verifiedUser?.data.membership?.currentPoints,
|
||||||
|
},
|
||||||
|
input,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw unauthorizedError()
|
throw unauthorizedError()
|
||||||
}
|
}
|
||||||
@@ -677,7 +681,8 @@ export const hotelQueryRouter = router({
|
|||||||
let selectedRoomData = await getSelectedRoomAvailability(
|
let selectedRoomData = await getSelectedRoomAvailability(
|
||||||
input,
|
input,
|
||||||
toApiLang(ctx.lang),
|
toApiLang(ctx.lang),
|
||||||
ctx.token
|
ctx.token,
|
||||||
|
ctx.userPoints
|
||||||
)
|
)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -575,7 +575,8 @@ function findProduct(product: Products, rateDefinition: RateDefinition) {
|
|||||||
export async function getSelectedRoomAvailability(
|
export async function getSelectedRoomAvailability(
|
||||||
input: z.input<typeof selectedRoomAvailabilityInputSchema>,
|
input: z.input<typeof selectedRoomAvailabilityInputSchema>,
|
||||||
lang: string,
|
lang: string,
|
||||||
serviceToken: string
|
serviceToken: string,
|
||||||
|
userPoints?: number
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
adults,
|
adults,
|
||||||
@@ -696,9 +697,10 @@ export async function getSelectedRoomAvailability(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(product)) {
|
if (Array.isArray(product)) {
|
||||||
const redemptionProduct = product.find(
|
const redemptionProduct = userPoints ? product.find(
|
||||||
(r) => r.redemption.rateCode === rateDefinition.rateCode
|
(r) => r.redemption.rateCode === rateDefinition.rateCode &&
|
||||||
)
|
r.redemption.localPrice.pointsPerStay <= userPoints
|
||||||
|
) : undefined
|
||||||
if (!redemptionProduct) {
|
if (!redemptionProduct) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user