Skip to content

Commit

Permalink
feat(suite): hide rewards button for unknown data
Browse files Browse the repository at this point in the history
  • Loading branch information
izmy committed Jan 15, 2025
1 parent 6bc3217 commit be07c74
Showing 1 changed file with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Text, Column } from '@trezor/components';
import { Text, Column, FractionButtonProps } from '@trezor/components';
import { spacings } from '@trezor/theme';
import { formInputsMaxLength } from '@suite-common/validators';
import { useFormatters } from '@suite-common/formatters';
Expand Down Expand Up @@ -44,8 +44,11 @@ export const Inputs = () => {
restakedReward = '0',
} = getStakingDataForNetwork(account) ?? {};

const isRewardsVisible = restakedReward != '';
const isRewardsDisabled = restakedReward === '0';

console.log({ restakedReward });

const { symbol } = account;
const networkDisplaySymbol = getNetworkDisplaySymbol(symbol);

Expand Down Expand Up @@ -171,24 +174,31 @@ export const Inputs = () => {
),
onClick: () => onCryptoAmountChange(autocompoundBalance),
},
{
id: 'TR_FRACTION_BUTTONS_REWARDS',
children: <Translation id="TR_FRACTION_BUTTONS_REWARDS" />,
tooltip: isRewardsDisabled ? (
<Translation id="TR_STAKE_NO_REWARDS" />
) : (
<Column alignItems="flex-end">
<FormattedCryptoAmount value={restakedReward} symbol={symbol} />
<Text variant="primary">
<FiatValue amount={restakedReward} symbol={symbol} />
</Text>
</Column>
),
isSubtle: true,
variant: 'primary',
isDisabled: isRewardsDisabled,
onClick: () => onCryptoAmountChange(restakedReward),
},
...(isRewardsVisible
? [
{
id: 'TR_FRACTION_BUTTONS_REWARDS',
children: <Translation id="TR_FRACTION_BUTTONS_REWARDS" />,
tooltip: isRewardsDisabled ? (
<Translation id="TR_STAKE_NO_REWARDS" />
) : (
<Column alignItems="flex-end">
<FormattedCryptoAmount
value={restakedReward}
symbol={symbol}
/>
<Text variant="primary">
<FiatValue amount={restakedReward} symbol={symbol} />
</Text>
</Column>
),
isSubtle: true,
variant: 'primary',
isDisabled: isRewardsDisabled,
onClick: () => onCryptoAmountChange(restakedReward),
} as FractionButtonProps,
]
: []),
]}
/>
</Column>
Expand Down

0 comments on commit be07c74

Please sign in to comment.