-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrewards.interface.ts
More file actions
133 lines (120 loc) · 3.64 KB
/
rewards.interface.ts
File metadata and controls
133 lines (120 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MIT
// Single source of truth for reward categories. The union type below is derived
// from this tuple, and `RewardPromotionGroups` keys off the union — adding a
// new category requires editing only this array.
export const REWARD_CATEGORIES = ['Event', 'Training', 'Certification'] as const;
export type RewardPromotionCategory = (typeof REWARD_CATEGORIES)[number];
export interface RewardPromotionProduct {
ID?: string;
Name?: string;
LogoURL?: string;
}
/**
* Raw promotion shape from user-service GET /v1/me/promotions.
* The endpoint returns a paginated envelope; see `RewardPromotionsPage`.
*/
export interface RewardPromotionRaw {
PromotionID?: string;
Category?: RewardPromotionCategory | string;
Description?: string;
Discount?: number;
DiscountType?: string;
RequiredRewards?: number;
RelativeExpiryInterval?: number;
ExpiresAT?: string;
Coupon?: string;
Eligible?: boolean;
Redeemed?: boolean;
EligiblityComment?: string;
LogoURL?: string;
Products?: RewardPromotionProduct[];
TIContentTypes?: string[];
MaxRedemptions?: number;
StartingAT?: string;
}
/**
* Paginated envelope returned by user-service GET /v1/me/promotions.
* `Metadata.TotalSize` is the source of truth for "are there more pages?";
* `Offset` and `PageSize` echo the request parameters.
*/
export interface RewardPromotionsPage {
Data?: RewardPromotionRaw[];
Metadata?: {
Offset?: number;
PageSize?: number;
TotalSize?: number;
};
}
export interface RewardPromotion {
id: string;
uid: string;
category: RewardPromotionCategory;
title: string;
discountLabel: string;
redeemPoints: number;
eligible: boolean;
redeemed: boolean;
coupon: string;
expiresAt: string;
relativeExpiryInterval: number;
eligibilityComment: string;
logo: string;
}
export interface RewardPromotionGroup {
earned: RewardPromotion[];
redeemable: RewardPromotion[];
}
export type RewardPromotionGroups = Record<RewardPromotionCategory, RewardPromotionGroup>;
export interface RewardCouponGenerationResponse {
PromotionID: string;
CouponCode: string;
}
export interface RewardsSummaryResponse {
points: number;
nextRewardPoints: number;
pointsToNextReward: number;
progressPercentage: number;
programStartDate: string | null;
programExpiryDate: string | null;
groupedPromotions: RewardPromotionGroups;
availableIncentives: RewardPromotion[];
coupons: RewardPromotion[];
}
/**
* Per-item display projection for the Available Incentives panel.
* Pre-computed once per data refresh so the template performs no method calls.
*/
export interface DecoratedAvailableIncentive extends RewardPromotion {
hasCouponCode: boolean;
canClaim: boolean;
statusLabel: string;
statusColorClass: string;
applicationHint: string;
resolvedExpiryDate: string | null;
isExpired: boolean;
}
/**
* Per-item display projection for the My Coupons panel.
* Pre-computed once per data refresh so the template performs no method calls.
*/
export interface DecoratedCoupon extends RewardPromotion {
hasCouponCode: boolean;
pointsShortfall: number;
resolvedExpiryDate: string | null;
isExpired: boolean;
statusLabel: string;
statusColorClass: string;
description: string;
}
/**
* Declarative state container for the rewards summary fetch.
* `data` retains the previously loaded summary during refreshes so the UI
* does not flash back to the skeleton on subsequent loads. Errors clear
* `data` to surface the dedicated error view.
*/
export interface RewardsState {
loading: boolean;
error: string | null;
data: RewardsSummaryResponse | null;
}