fix(LOY-175): fix issues of getting correct expiration date on reward coupon
This commit is contained in:
@@ -70,9 +70,7 @@ export default function ClientCurrentRewards({
|
||||
<div ref={containerRef} className={styles.container}>
|
||||
<Grids.Stackable>
|
||||
{paginatedRewards.map((reward, idx) => {
|
||||
const earliestExpirationDate = getEarliestExpirationDate(
|
||||
reward.data.coupon
|
||||
)
|
||||
const earliestExpirationDate = getEarliestExpirationDate(reward.data)
|
||||
|
||||
return (
|
||||
<article className={styles.card} key={`${reward.reward_id}-${idx}`}>
|
||||
|
||||
@@ -7,7 +7,7 @@ import Card from "./Card"
|
||||
import type { SlideProps } from "@/types/components/blocks/surprises"
|
||||
|
||||
export default function Slide({ surprise }: SlideProps) {
|
||||
const earliestExpirationDate = getEarliestExpirationDate(surprise.coupons)
|
||||
const earliestExpirationDate = getEarliestExpirationDate(surprise.data)
|
||||
|
||||
return (
|
||||
<Card title={surprise.label}>
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user