Skip to content

Commit

Permalink
fix: token icons on incentives [skip cypress] (#2210)
Browse files Browse the repository at this point in the history
  • Loading branch information
foodaka authored Oct 10, 2024
1 parent 83b4835 commit 3b5846c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 57 deletions.
36 changes: 21 additions & 15 deletions src/components/incentives/IncentivesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DASHBOARD } from 'src/utils/mixPanelEvents';
import { ContentWithTooltip } from '../ContentWithTooltip';
import { FormattedNumber } from '../primitives/FormattedNumber';
import { TokenIcon } from '../primitives/TokenIcon';
import { IncentivesTooltipContent } from './IncentivesTooltipContent';
import { getSymbolMap, IncentivesTooltipContent } from './IncentivesTooltipContent';
import { MeritIncentivesTooltipContent } from './MeritIncentivesTooltipContent';

interface IncentivesButtonProps {
Expand Down Expand Up @@ -229,23 +229,29 @@ const Content = ({
<>
{incentives.length < 5 ? (
<>
{incentives.map((incentive) => (
<TokenIcon
symbol={incentive.rewardTokenSymbol}
sx={{ fontSize: `${iconSize}px`, ml: -1 }}
key={incentive.rewardTokenSymbol}
/>
))}
{incentives.map(getSymbolMap).map((incentive) => {
return (
<TokenIcon
aToken={incentive.aToken}
symbol={incentive.tokenIconSymbol}
sx={{ fontSize: `${iconSize}px`, ml: -1 }}
key={incentive.tokenIconSymbol}
/>
);
})}
</>
) : (
<>
{incentives.slice(0, 3).map((incentive) => (
<TokenIcon
symbol={incentive.rewardTokenSymbol}
sx={{ fontSize: `${iconSize}px`, ml: -1 }}
key={incentive.rewardTokenSymbol}
/>
))}
{incentives
.slice(0, 3)
.map(getSymbolMap)
.map((incentive) => (
<TokenIcon
symbol={incentive.tokenIconSymbol}
sx={{ fontSize: `${iconSize}px`, ml: -1 }}
key={incentive.tokenIconSymbol}
/>
))}
<SvgIcon
sx={{
fontSize: `${iconSize}px`,
Expand Down
86 changes: 44 additions & 42 deletions src/components/incentives/IncentivesTooltipContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ interface IncentivesTooltipContentProps {
symbol: string;
}

export const getSymbolMap = (incentive: ReserveIncentiveResponse) => {
const rewardTokenSymbol = incentive.rewardTokenSymbol;

return IncentivesSymbolMap[rewardTokenSymbol]
? {
...IncentivesSymbolMap[rewardTokenSymbol],
rewardTokenAddress: incentive.rewardTokenAddress,
incentiveAPR: incentive.incentiveAPR,
}
: {
...incentive,
tokenIconSymbol: rewardTokenSymbol,
symbol: rewardTokenSymbol,
aToken: false,
};
};

export const IncentivesTooltipContent = ({
incentives,
incentivesNetAPR,
Expand Down Expand Up @@ -65,23 +82,6 @@ export const IncentivesTooltipContent = ({
);
};

const getSymbolMap = (incentive: ReserveIncentiveResponse) => {
const rewardTokenSymbol = incentive.rewardTokenSymbol;

return IncentivesSymbolMap[rewardTokenSymbol]
? {
...IncentivesSymbolMap[rewardTokenSymbol],
rewardTokenAddress: incentive.rewardTokenAddress,
incentiveAPR: incentive.incentiveAPR,
}
: {
...incentive,
tokenIconSymbol: rewardTokenSymbol,
symbol: rewardTokenSymbol,
aToken: false,
};
};

return (
<Box
sx={{
Expand All @@ -96,31 +96,33 @@ export const IncentivesTooltipContent = ({
</Typography>

<Box sx={{ width: '100%' }}>
{incentives.map(getSymbolMap).map((incentive) => (
<Row
height={32}
caption={
<Box
sx={{
display: 'flex',
alignItems: 'center',
mb: incentives.length > 1 ? 2 : 0,
}}
>
<TokenIcon
aToken={incentive.aToken}
symbol={incentive.tokenIconSymbol}
sx={{ fontSize: '20px', mr: 1 }}
/>
<Typography variant={typographyVariant}>{incentive.symbol}</Typography>
</Box>
}
key={incentive.rewardTokenAddress}
width="100%"
>
<Number incentiveAPR={incentive.incentiveAPR} />
</Row>
))}
{incentives.map(getSymbolMap).map((incentive) => {
return (
<Row
height={32}
caption={
<Box
sx={{
display: 'flex',
alignItems: 'center',
mb: incentives.length > 1 ? 2 : 0,
}}
>
<TokenIcon
aToken={incentive.aToken}
symbol={incentive.tokenIconSymbol}
sx={{ fontSize: '20px', mr: 1 }}
/>
<Typography variant={typographyVariant}>{incentive.symbol}</Typography>
</Box>
}
key={incentive.rewardTokenAddress}
width="100%"
>
<Number incentiveAPR={incentive.incentiveAPR} />
</Row>
);
})}

{incentives.length > 1 && (
<Box sx={() => ({ pt: 1, mt: 1 })}>
Expand Down

2 comments on commit 3b5846c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.