refactor(LOY-175): rewrite reward types according to new api endpoints

This commit is contained in:
Christian Andolf
2025-03-11 16:09:15 +01:00
parent 0ae4c5db17
commit b86347b4f4
15 changed files with 196 additions and 246 deletions

View File

@@ -19,10 +19,10 @@ import Redeem from "../Redeem"
import styles from "./current.module.css"
import type { CurrentRewardsClientProps } from "@/types/components/myPages/myPage/accountPage"
import type {
Reward,
RewardWithRedeem,
} from "@/server/routers/contentstack/reward/output"
import {
type Reward,
type RewardWithRedeem,
} from "@/types/components/myPages/rewards"
export default function ClientCurrentRewards({
rewards: initialData,
@@ -70,21 +70,15 @@ export default function ClientCurrentRewards({
<div ref={containerRef} className={styles.container}>
<Grids.Stackable>
{paginatedRewards.map((reward, idx) => {
const earliestExpirationDate =
"coupons" in reward
? getEarliestExpirationDate(reward.coupons)
: null
const earliestExpirationDate = getEarliestExpirationDate(
reward.data.coupon
)
return (
<article className={styles.card} key={`${reward.reward_id}-${idx}`}>
<div className={styles.content}>
<RewardIcon rewardId={reward.reward_id} />
{showRedeem && (
<ScriptedRewardText
rewardType={reward.rewardType}
rewardTierLevel={reward.rewardTierLevel}
/>
)}
{showRedeem && <ScriptedRewardText reward={reward} />}
<Title
as="h4"
level="h3"