Skip to content

Commit 0606572

Browse files
Revert "feat: [LW-7837] add warning banner for retiring, retired and saturated stake pools (#659)" (#676)
This reverts commit a7ce973.
1 parent 40bdf2c commit 0606572

File tree

16 files changed

+97
-144
lines changed

16 files changed

+97
-144
lines changed

packages/staking/src/features/i18n/translations/en.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ export const en: Translations = {
106106
'overview.banners.portfolioDrifted.message':
107107
'Make sure to rebalance your staking ratios if you want to match your preferences',
108108
'overview.banners.portfolioDrifted.title': 'Your current delegation portfolio has shifted',
109-
'overview.banners.saturatedOrRetiredPool.message': 'Please make sure to choose other pool(s) to avoid losing rewards',
110-
'overview.banners.saturatedOrRetiredPool.title': 'One or several of your pools are too saturated / retired',
111109
'overview.delegationCard.label.balance': 'ADA Balance',
112110
'overview.delegationCard.label.pools': 'Pool(s)',
113111
'overview.delegationCard.label.status': 'Status',
@@ -134,7 +132,6 @@ export const en: Translations = {
134132
'overview.stakingInfoCard.lastReward': 'Last reward',
135133
'overview.stakingInfoCard.margin': 'Margin',
136134
'overview.stakingInfoCard.poolRetired': 'Pool retired',
137-
'overview.stakingInfoCard.poolRetiring': 'Pool retiring',
138135
'overview.stakingInfoCard.poolSaturated': 'Pool over-saturated',
139136
'overview.stakingInfoCard.ros': 'ROS',
140137
'overview.stakingInfoCard.tooltipFiatLabel': 'USD Value',

packages/staking/src/features/i18n/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ type KeysStructure = {
192192
title: '';
193193
message: '';
194194
};
195-
saturatedOrRetiredPool: {
196-
title: '';
197-
message: '';
198-
};
199195
};
200196
stakingInfoCard: {
201197
fee: '';
@@ -205,7 +201,6 @@ type KeysStructure = {
205201
totalRewards: '';
206202
totalStaked: '';
207203
poolRetired: '';
208-
poolRetiring: '';
209204
poolSaturated: '';
210205
tooltipFiatLabel: '';
211206
};

packages/staking/src/features/overview/Overview.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { GetStartedSteps } from './GetStartedSteps';
1010
import { hasMinimumFundsToDelegate, hasPendingDelegationTransaction, mapPortfolioToDisplayData } from './helpers';
1111
import { StakeFundsBanner } from './StakeFundsBanner';
1212
import { StakingInfoCard } from './StakingInfoCard';
13-
import { StakingNotificationBanners, getCurrentStakingNotifications } from './StakingNotificationBanner';
13+
import { StakingNotificationBanner, getCurrentStakingNotification } from './StakingNotificationBanner';
1414

1515
export const Overview = () => {
1616
const { t } = useTranslation();
@@ -29,7 +29,7 @@ export const Overview = () => {
2929
currentPortfolio: store.currentPortfolio,
3030
portfolioMutators: store.mutators,
3131
}));
32-
const stakingNotification = getCurrentStakingNotifications({ currentPortfolio, walletActivities });
32+
const stakingNotification = getCurrentStakingNotification({ currentPortfolio, walletActivities });
3333

3434
const totalCoinBalance = balancesBalance?.total?.coinBalance;
3535

@@ -76,7 +76,10 @@ export const Overview = () => {
7676
return (
7777
<>
7878
{stakingNotification ? (
79-
<StakingNotificationBanners notifications={stakingNotification} onClickableBannerClick={onManageClick} />
79+
<StakingNotificationBanner
80+
notification={stakingNotification}
81+
onPortfolioDriftedNotificationClick={onManageClick}
82+
/>
8083
) : (
8184
<Flex flexDirection="column" gap="$32">
8285
<StakeFundsBanner balance={totalCoinBalance} />
@@ -104,7 +107,10 @@ export const Overview = () => {
104107
</Box>
105108
{stakingNotification && (
106109
<Box mb="$40">
107-
<StakingNotificationBanners notifications={stakingNotification} onClickableBannerClick={onManageClick} />
110+
<StakingNotificationBanner
111+
notification={stakingNotification}
112+
onPortfolioDriftedNotificationClick={onManageClick}
113+
/>
108114
</Box>
109115
)}
110116
<Flex justifyContent="space-between" mb="$16">

packages/staking/src/features/overview/OverviewPopup.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { FundWalletBanner } from './FundWalletBanner';
1212
import { hasMinimumFundsToDelegate, mapPortfolioToDisplayData } from './helpers';
1313
import { StakeFundsBanner } from './StakeFundsBanner';
1414
import { StakingInfoCard } from './StakingInfoCard';
15-
import { StakingNotificationBanners, getCurrentStakingNotifications } from './StakingNotificationBanner';
15+
import { StakingNotificationBanner, getCurrentStakingNotification } from './StakingNotificationBanner';
1616

1717
export const OverviewPopup = () => {
1818
const { t } = useTranslation();
@@ -32,7 +32,7 @@ export const OverviewPopup = () => {
3232
currentPortfolio: store.currentPortfolio,
3333
portfolioMutators: store.mutators,
3434
}));
35-
const stakingNotifications = getCurrentStakingNotifications({ currentPortfolio, walletActivities });
35+
const stakingNotification = getCurrentStakingNotification({ currentPortfolio, walletActivities });
3636

3737
const totalCoinBalance = balancesBalance?.total?.coinBalance || '0';
3838

@@ -85,16 +85,11 @@ export const OverviewPopup = () => {
8585

8686
return (
8787
<>
88-
{stakingNotifications.includes('portfolioDrifted') && (
88+
{stakingNotification === 'portfolioDrifted' && (
8989
<Box mb="$32">
90-
<StakingNotificationBanners notifications={['portfolioDrifted']} onClickableBannerClick={expandStakingView} />
91-
</Box>
92-
)}
93-
{stakingNotifications.includes('poolRetiredOrSaturated') && (
94-
<Box mb="$32">
95-
<StakingNotificationBanners
96-
notifications={['poolRetiredOrSaturated']}
97-
onClickableBannerClick={expandStakingView}
90+
<StakingNotificationBanner
91+
notification="portfolioDrifted"
92+
onPortfolioDriftedNotificationClick={expandStakingView}
9893
/>
9994
</Box>
10095
)}

packages/staking/src/features/overview/StakingInfoCard/StakingInfoCard.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { getRandomIcon } from '@lace/common';
44
import { Flex } from '@lace/ui';
55
import BigNumber from 'bignumber.js';
66
import cn from 'classnames';
7-
import React, { ReactNode } from 'react';
7+
import React from 'react';
88
import { useTranslation } from 'react-i18next';
9-
import MoonIcon from '../../../assets/icons/moon.component.svg';
10-
import WarningIcon from '../../../assets/icons/warning.component.svg';
119
import { TranslationKey } from '../../i18n';
10+
import MoonIcon from './moon.component.svg';
1211
import { StakePoolInfo } from './StakePoolInfo';
1312
import styles from './StakingInfoCard.module.scss';
1413
import { Stats } from './Stats';
1514
import { Tooltip } from './StatsTooltip';
15+
import WarningIon from './warning.component.svg';
1616

1717
const DEFAULT_DECIMALS = 2;
1818

@@ -34,7 +34,7 @@ const formatNumericValue = (
3434
</>
3535
);
3636

37-
export type PoolStatus = 'retired' | 'saturated' | 'retiring';
37+
type PoolStatus = 'retired' | 'saturated';
3838

3939
export type StakingInfoCardProps = {
4040
className?: string;
@@ -56,15 +56,13 @@ export type StakingInfoCardProps = {
5656
status?: PoolStatus;
5757
};
5858

59-
const iconsByPoolStatus: Record<PoolStatus, ReactNode> = {
60-
retired: <Icon style={{ color: '#FF8E3C', fontSize: '24px' }} component={MoonIcon} />,
61-
retiring: <Icon style={{ color: '#FDC300', fontSize: '24px' }} component={MoonIcon} />,
62-
saturated: <Icon style={{ color: '#FF5470', fontSize: '24px' }} component={WarningIcon} />,
59+
const iconsByPoolStatus: Record<PoolStatus, React.FC<React.SVGProps<SVGSVGElement>>> = {
60+
retired: MoonIcon,
61+
saturated: WarningIon,
6362
};
6463

6564
const labelTranslationKeysByPoolStatus: Record<PoolStatus, TranslationKey> = {
6665
retired: 'overview.stakingInfoCard.poolRetired',
67-
retiring: 'overview.stakingInfoCard.poolRetiring',
6866
saturated: 'overview.stakingInfoCard.poolSaturated',
6967
};
7068

@@ -104,8 +102,10 @@ export const StakingInfoCard = ({
104102
id={id}
105103
onClick={onStakePoolSelect}
106104
/>
107-
{(status === 'retired' || status === 'saturated' || status === 'retiring') && (
108-
<Tooltip content={t(labelTranslationKeysByPoolStatus[status])}>{iconsByPoolStatus[status]}</Tooltip>
105+
{(status === 'retired' || status === 'saturated') && (
106+
<Tooltip content={t(labelTranslationKeysByPoolStatus[status])}>
107+
<Icon style={{ color: '#FF5470', fontSize: '24px' }} component={iconsByPoolStatus[status]} />
108+
</Tooltip>
109109
)}
110110
</Flex>
111111
</div>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Banner } from '@lace/common';
2+
import { useTranslation } from 'react-i18next';
3+
import BellIcon from '../../../assets/icons/bell-icon.component.svg';
4+
import InfoIcon from '../../../assets/icons/info-icon.svg';
5+
import * as styles from './StakingNotificationBanner.css';
6+
import { StakingNotificationType } from './types';
7+
8+
type StakingNotificationBannerProps = {
9+
popupView?: boolean;
10+
notification: StakingNotificationType;
11+
onPortfolioDriftedNotificationClick?: () => void;
12+
};
13+
14+
export const StakingNotificationBanner = ({
15+
popupView,
16+
notification,
17+
onPortfolioDriftedNotificationClick,
18+
}: StakingNotificationBannerProps) => {
19+
const { t } = useTranslation();
20+
21+
switch (notification) {
22+
case 'pendingFirstDelegation':
23+
return (
24+
<Banner
25+
popupView={popupView}
26+
withIcon
27+
customIcon={<InfoIcon className={styles.bannerInfoIcon} />}
28+
message={t('overview.banners.pendingFirstDelegation.title')}
29+
description={t('overview.banners.pendingFirstDelegation.message')}
30+
/>
31+
);
32+
case 'pendingPoolMigration':
33+
return (
34+
<Banner
35+
popupView={popupView}
36+
withIcon
37+
customIcon={<InfoIcon className={styles.bannerInfoIcon} />}
38+
message={t('overview.banners.pendingPoolMigration.title')}
39+
description={t('overview.banners.pendingPoolMigration.message')}
40+
/>
41+
);
42+
case 'portfolioDrifted':
43+
return (
44+
<Banner
45+
popupView={popupView}
46+
withIcon
47+
customIcon={<BellIcon className={styles.bannerInfoIcon} />}
48+
message={t('overview.banners.portfolioDrifted.title')}
49+
description={t('overview.banners.portfolioDrifted.message')}
50+
onBannerClick={onPortfolioDriftedNotificationClick}
51+
/>
52+
);
53+
default:
54+
return <></>;
55+
}
56+
};

packages/staking/src/features/overview/StakingNotificationBanner/StakingNotificationBanners.tsx

Lines changed: 0 additions & 70 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
import type { CurrentPortfolioStakePool } from '../../store';
22
import type { StakingNotificationType } from './types';
33
import type { AssetActivityListProps } from '@lace/core';
4-
import { hasPendingDelegationTransaction, hasSaturatedOrRetiredPools, isPortfolioDrifted } from '../helpers';
4+
import { hasPendingDelegationTransaction, isPortfolioDrifted } from '../helpers';
55

66
type GetCurrentStakingNotificationParams = {
77
walletActivities: AssetActivityListProps[];
88
currentPortfolio: CurrentPortfolioStakePool[];
99
};
1010

11-
export const getCurrentStakingNotifications = ({
11+
export const getCurrentStakingNotification = ({
1212
walletActivities,
1313
currentPortfolio,
14-
}: GetCurrentStakingNotificationParams): StakingNotificationType[] => {
14+
}: GetCurrentStakingNotificationParams): StakingNotificationType | null => {
1515
const pendingDelegationTransaction = hasPendingDelegationTransaction(walletActivities);
16-
const notifications: StakingNotificationType[] = [];
1716

1817
if (pendingDelegationTransaction) {
19-
currentPortfolio.length === 0
20-
? notifications.push('pendingFirstDelegation')
21-
: notifications.push('pendingPoolMigration');
18+
return currentPortfolio.length === 0 ? 'pendingFirstDelegation' : 'pendingPoolMigration';
2219
}
2320

2421
if (isPortfolioDrifted(currentPortfolio)) {
25-
notifications.push('portfolioDrifted');
22+
return 'portfolioDrifted';
2623
}
2724

28-
if (hasSaturatedOrRetiredPools(currentPortfolio)) {
29-
notifications.push('poolRetiredOrSaturated');
30-
}
31-
32-
return notifications;
25+
return null;
3326
};

0 commit comments

Comments
 (0)