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

@@ -0,0 +1,23 @@
import { isValidSession } from "./session"
import type { Session } from "next-auth"
export function getRedemptionTokenSafely(
session: Session,
serviceToken: string
): string | undefined {
if (!isValidSession(session)) return undefined
// ToDo- Get Curity based token when linked user is logged in
// const token =
// session.token.loginType === "sas"
// ? session.token.curity_access_token ?? serviceToken
// : session.token.access_token
const token =
session.token.loginType === "sas"
? serviceToken
: session.token.access_token
return token
}

View File

@@ -0,0 +1,27 @@
import { getEuroBonusProfileData } from "../routers/partners/sas/getEuroBonusProfile"
import { getVerifiedUser } from "../routers/user/utils/getVerifiedUser"
import { isValidSession } from "./session"
import type { Session } from "next-auth"
export async function getUserPointsBalance(
session: Session | null
): Promise<number | undefined> {
if (!isValidSession(session)) return undefined
const verifiedUser =
session.token.loginType === "sas"
? await getEuroBonusProfileData(session)
: await getVerifiedUser({ session })
if (!verifiedUser || "error" in verifiedUser) {
return undefined
}
const points =
"points" in verifiedUser.data
? verifiedUser.data.points.total
: verifiedUser.data.membership?.currentPoints
return points ?? 0
}