Skip to content

Commit b3e6c15

Browse files
authored
feat: replace emode label underscore with spaces (#2908)
1 parent 86bb3b3 commit b3e6c15

7 files changed

Lines changed: 30 additions & 13 deletions

File tree

src/components/transactions/Emode/EmodeModalContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { useModalContext } from 'src/hooks/useModal';
2929
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
3030
import { useRootStore } from 'src/store/root';
3131
import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig';
32+
import { replaceUnderscoresWithSpaces } from 'src/utils/utils';
3233
import { useShallow } from 'zustand/shallow';
3334

3435
import { TxErrorView } from '../FlowCommons/Error';
@@ -437,7 +438,7 @@ export const EmodeModalContent = ({ user }: { user: ExtendedFormattedUser }) =>
437438
sx={{ opacity: emode.available ? 1 : 0.5 }}
438439
fontStyle={emode.available ? 'normal' : 'italic'}
439440
>
440-
{emode.label}
441+
{replaceUnderscoresWithSpaces(emode.label)}
441442
</Typography>
442443
{emode.id === user.userEmodeCategoryId && (
443444
<Box sx={{ display: 'inline-flex', alignItems: 'center' }}>

src/components/transactions/Supply/SupplyModalContent.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
} from 'src/utils/getMaxAmountAvailableToSupply';
3131
import { calculateHFAfterSupply } from 'src/utils/hfUtils';
3232
import { isFeatureEnabled } from 'src/utils/marketsAndNetworksConfig';
33-
import { roundToTokenDecimals } from 'src/utils/utils';
33+
import { replaceUnderscoresWithSpaces, roundToTokenDecimals } from 'src/utils/utils';
3434
import { useShallow } from 'zustand/shallow';
3535

3636
import {
@@ -372,7 +372,8 @@ export const SupplyModalContent = React.memo(
372372
text={
373373
selectedEmodeId === 0
374374
? t`Disabled`
375-
: eModes[selectedEmodeId]?.label || t`Category ${selectedEmodeId}`
375+
: replaceUnderscoresWithSpaces(eModes[selectedEmodeId]?.label) ||
376+
t`Category ${selectedEmodeId}`
376377
}
377378
/>
378379
)}
@@ -391,8 +392,9 @@ export const SupplyModalContent = React.memo(
391392
<Typography variant="caption">
392393
{user.userEmodeCategoryId === 0 ? (
393394
<Trans>
394-
This transaction will enable E-Mode ({eModes[selectedEmodeId]?.label}). Borrowing
395-
will be restricted to assets within this category.
395+
This transaction will enable E-Mode (
396+
{replaceUnderscoresWithSpaces(eModes[selectedEmodeId]?.label)}). Borrowing will be
397+
restricted to assets within this category.
396398
</Trans>
397399
) : selectedEmodeId === 0 ? (
398400
<Trans>
@@ -401,9 +403,10 @@ export const SupplyModalContent = React.memo(
401403
</Trans>
402404
) : (
403405
<Trans>
404-
This transaction will switch E-Mode from {eModes[user.userEmodeCategoryId]?.label}{' '}
405-
to {eModes[selectedEmodeId]?.label}. Borrowing will be restricted to assets within
406-
the new category.
406+
This transaction will switch E-Mode from{' '}
407+
{replaceUnderscoresWithSpaces(eModes[user.userEmodeCategoryId]?.label)} to{' '}
408+
{replaceUnderscoresWithSpaces(eModes[selectedEmodeId]?.label)}. Borrowing will be
409+
restricted to assets within the new category.
407410
</Trans>
408411
)}
409412
{supplyUnWrapped && (

src/hooks/useReserveActionState.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { WalletEmptyInfo } from 'src/modules/dashboard/lists/SupplyAssetsList/Wa
1313
import { useRootStore } from 'src/store/root';
1414
import { assetCanBeBorrowedByUser } from 'src/utils/getMaxAmountAvailableToBorrow';
1515
import { displayGhoForMintableMarket } from 'src/utils/ghoUtilities';
16+
import { replaceUnderscoresWithSpaces } from 'src/utils/utils';
1617
import { useShallow } from 'zustand/shallow';
1718

1819
import { useModalContext } from './useModal';
@@ -137,8 +138,11 @@ export const useReserveActionState = ({
137138
<Warning sx={{ mb: 0 }} severity="info" icon={false}>
138139
<Trans>
139140
Borrowing is unavailable because you’ve enabled Efficiency Mode (E-Mode) for{' '}
140-
{getEmodeMessage(eModes[user.userEmodeCategoryId].label)} category. To manage E-Mode
141-
categories visit your <Link href={ROUTES.dashboard}>Dashboard</Link>.
141+
{replaceUnderscoresWithSpaces(
142+
getEmodeMessage(eModes[user.userEmodeCategoryId].label)
143+
)}{' '}
144+
category. To manage E-Mode categories visit your{' '}
145+
<Link href={ROUTES.dashboard}>Dashboard</Link>.
142146
</Trans>
143147
</Warning>
144148
)}

src/modules/dashboard/DashboardEModeButton.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useAppDataContext } from 'src/hooks/app-data-provider/useAppDataProvide
77
import { useModalContext } from 'src/hooks/useModal';
88
import { useRootStore } from 'src/store/root';
99
import { DASHBOARD, GENERAL } from 'src/utils/events';
10+
import { replaceUnderscoresWithSpaces } from 'src/utils/utils';
1011

1112
import LightningBoltGradient from '/public/lightningBoltGradient.svg';
1213

@@ -40,7 +41,9 @@ export const DashboardEModeButton = ({ userEmodeCategoryId }: DashboardEModeButt
4041
const isEModeDisabled = userEmodeCategoryId === 0;
4142

4243
const EModeLabelMessage = () => (
43-
<Trans>{getEmodeMessage(_eModes[userEmodeCategoryId].label)}</Trans>
44+
<Trans>
45+
{replaceUnderscoresWithSpaces(getEmodeMessage(_eModes[userEmodeCategoryId].label))}
46+
</Trans>
4447
);
4548

4649
return (

src/modules/reserve-overview/ReserveEModePanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ReserveOverviewBox } from 'src/components/ReserveOverviewBox';
1313
import { ReserveWithId } from 'src/hooks/app-data-provider/useAppDataProvider';
1414
import { useRootStore } from 'src/store/root';
1515
import { GENERAL, RESERVE_DETAILS } from 'src/utils/events';
16+
import { replaceUnderscoresWithSpaces } from 'src/utils/utils';
1617

1718
import LightningBoltGradient from '/public/lightningBoltGradient.svg';
1819

@@ -35,7 +36,7 @@ export const ReserveEModePanel: React.FC<ReserverEModePanelProps> = ({ reserve }
3536
<SvgIcon sx={{ fontSize: '14px', mr: 0.5, ml: 2 }}>
3637
<LightningBoltGradient />
3738
</SvgIcon>
38-
<Typography variant="subheader1">{e.label}</Typography>
39+
<Typography variant="subheader1">{replaceUnderscoresWithSpaces(e.label)}</Typography>
3940
<ConfigStatus
4041
enabled={e.canBeCollateral}
4142
label="Collateral"

src/modules/reserve-overview/SupplyInfo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ReserveWithId } from 'src/hooks/app-data-provider/useAppDataProvider';
1919
import { AssetCapHookData } from 'src/hooks/useAssetCapsSDK';
2020
import { GENERAL } from 'src/utils/events';
2121
import { MarketDataType } from 'src/utils/marketsAndNetworksConfig';
22+
import { replaceUnderscoresWithSpaces } from 'src/utils/utils';
2223

2324
import { SupplyApyGraph } from './graphs/ApyGraphContainer';
2425
import { ConfigStatus } from './ReserveEModePanel';
@@ -221,7 +222,7 @@ export const SupplyInfo = ({
221222
This asset can only be used as collateral in E-Mode:{' '}
222223
{reserve.eModeInfo
223224
?.filter((eMode) => eMode.canBeCollateral)
224-
.map((eMode) => eMode.label)
225+
.map((eMode) => replaceUnderscoresWithSpaces(eMode.label))
225226
.join(', ')}
226227
</Trans>
227228
</Warning>

src/utils/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,7 @@ export const convertAprToApy = (apr: number): number => {
145145
const apy = Math.pow(1 + monthlyRate, 12) - 1;
146146
return apy;
147147
};
148+
149+
export const replaceUnderscoresWithSpaces = (str?: string): string | undefined => {
150+
return str?.replace(/_/g, ' ');
151+
};

0 commit comments

Comments
 (0)