fix(LOY-175): fix issues of getting correct expiration date on reward coupon

This commit is contained in:
Christian Andolf
2025-03-12 10:26:00 +01:00
parent b86347b4f4
commit 45d57a9c89
3 changed files with 4 additions and 7 deletions

View File

@@ -14,7 +14,6 @@ import type {
} from "@/types/components/myPages/rewards"
import type {
ApiReward,
Coupon,
RedeemableCoupon,
RedeemLocation,
} from "@/server/routers/contentstack/reward/output"
@@ -82,8 +81,8 @@ function getFirstRedeemableCoupon(reward: ApiReward): RedeemableCoupon {
return sortedCoupons[0]
}
function getEarliestExpirationDate(coupons: Coupon[]) {
return coupons
function getEarliestExpirationDate(reward: ApiReward) {
return getReedemableCoupons(reward)
.map(({ expiresAt }) => expiresAt)
.filter((expiresAt): expiresAt is string => !!expiresAt)
.reduce((earliestDate: Dayjs | null, expiresAt) => {