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}>
|
<div ref={containerRef} className={styles.container}>
|
||||||
<Grids.Stackable>
|
<Grids.Stackable>
|
||||||
{paginatedRewards.map((reward, idx) => {
|
{paginatedRewards.map((reward, idx) => {
|
||||||
const earliestExpirationDate = getEarliestExpirationDate(
|
const earliestExpirationDate = getEarliestExpirationDate(reward.data)
|
||||||
reward.data.coupon
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className={styles.card} key={`${reward.reward_id}-${idx}`}>
|
<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"
|
import type { SlideProps } from "@/types/components/blocks/surprises"
|
||||||
|
|
||||||
export default function Slide({ surprise }: SlideProps) {
|
export default function Slide({ surprise }: SlideProps) {
|
||||||
const earliestExpirationDate = getEarliestExpirationDate(surprise.coupons)
|
const earliestExpirationDate = getEarliestExpirationDate(surprise.data)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card title={surprise.label}>
|
<Card title={surprise.label}>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import type {
|
|||||||
} from "@/types/components/myPages/rewards"
|
} from "@/types/components/myPages/rewards"
|
||||||
import type {
|
import type {
|
||||||
ApiReward,
|
ApiReward,
|
||||||
Coupon,
|
|
||||||
RedeemableCoupon,
|
RedeemableCoupon,
|
||||||
RedeemLocation,
|
RedeemLocation,
|
||||||
} from "@/server/routers/contentstack/reward/output"
|
} from "@/server/routers/contentstack/reward/output"
|
||||||
@@ -82,8 +81,8 @@ function getFirstRedeemableCoupon(reward: ApiReward): RedeemableCoupon {
|
|||||||
return sortedCoupons[0]
|
return sortedCoupons[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEarliestExpirationDate(coupons: Coupon[]) {
|
function getEarliestExpirationDate(reward: ApiReward) {
|
||||||
return coupons
|
return getReedemableCoupons(reward)
|
||||||
.map(({ expiresAt }) => expiresAt)
|
.map(({ expiresAt }) => expiresAt)
|
||||||
.filter((expiresAt): expiresAt is string => !!expiresAt)
|
.filter((expiresAt): expiresAt is string => !!expiresAt)
|
||||||
.reduce((earliestDate: Dayjs | null, expiresAt) => {
|
.reduce((earliestDate: Dayjs | null, expiresAt) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user