Skip to content

Commit ce9e19e

Browse files
committed
fix: use enums for better readability
1 parent 680d32a commit ce9e19e

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

src/components/incentives/MeritIncentivesTooltipContent.tsx

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,50 @@ import { Row } from '../primitives/Row';
1212
import { TokenIcon } from '../primitives/TokenIcon';
1313
import { getSymbolMap } from './IncentivesTooltipContent';
1414

15-
const isCeloAction = (action: MeritAction): boolean => action.startsWith('celo-');
15+
export enum CampaignType {
16+
SELF_VERIFICATION = 'self_verification',
17+
CELO_STANDARD = 'celo_standard',
18+
STANDARD = 'standard',
19+
}
20+
interface CampaignConfig {
21+
type: CampaignType;
22+
title: string;
23+
hasSpecialContent: boolean;
24+
}
25+
26+
const isCeloAction = (action: MeritAction): boolean => {
27+
return [
28+
MeritAction.CELO_SUPPLY_CELO,
29+
MeritAction.CELO_SUPPLY_USDT,
30+
MeritAction.CELO_SUPPLY_USDC,
31+
MeritAction.CELO_SUPPLY_WETH,
32+
MeritAction.CELO_SUPPLY_MULTIPLE_BORROW_USDT,
33+
MeritAction.CELO_BORROW_CELO,
34+
MeritAction.CELO_BORROW_USDT,
35+
MeritAction.CELO_BORROW_USDC,
36+
MeritAction.CELO_BORROW_WETH,
37+
].includes(action);
38+
};
1639
const isSelfVerificationCampaign = (action: MeritAction): boolean =>
1740
action === MeritAction.CELO_SUPPLY_USDT;
1841

19-
const getCampaignConfig = (action: MeritAction) => {
42+
const getCampaignConfig = (action: MeritAction): CampaignConfig => {
2043
if (isSelfVerificationCampaign(action)) {
2144
return {
22-
type: 'self_verification' as const,
45+
type: CampaignType.SELF_VERIFICATION,
2346
title: 'Eligible for Merit program and Boosted Yield via Self.',
2447
hasSpecialContent: true,
2548
};
2649
}
2750
if (isCeloAction(action)) {
2851
return {
29-
type: 'celo_standard' as const,
52+
type: CampaignType.CELO_STANDARD,
3053
title: 'Eligible for Merit program.',
3154
hasSpecialContent: true,
3255
};
3356
}
3457
return {
35-
type: 'standard' as const,
58+
type: CampaignType.STANDARD,
3659
title: 'Eligible for the Merit program.',
3760
hasSpecialContent: false,
3861
};
@@ -93,7 +116,7 @@ export const MeritIncentivesTooltipContent = ({
93116
</Link>
94117
</Typography>
95118

96-
{campaignConfig.type === 'self_verification' && (
119+
{campaignConfig.type === CampaignType.SELF_VERIFICATION && (
97120
<>
98121
<Typography variant="caption" color="text.secondary">
99122
<Trans>
@@ -130,9 +153,11 @@ export const MeritIncentivesTooltipContent = ({
130153
</>
131154
)}
132155
{/* Show if SpecialContent is needed */}
133-
{/* {campaignConfig.type === 'self_verification' && campaignConfig.hasSpecialContent && ''} */}
156+
{/* {campaignConfig.type === CampaignType.SELF_VERIFICATION &&
157+
campaignConfig.hasSpecialContent &&
158+
''} */}
134159
{/* Show if SpecialContent is needed */}
135-
{/* {campaignConfig.type === 'celo_standard' && campaignConfig.hasSpecialContent && ''} */}
160+
{/* {campaignConfig.type === CampaignType.CELO_STANDARD && campaignConfig.hasSpecialContent && ''} */}
136161

137162
{meritIncentives.customMessage ? (
138163
<Typography variant="caption" color="text.secondary">

0 commit comments

Comments
 (0)