Skip to content

Commit

Permalink
Add support for hiding all fiat values
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Feb 21, 2024
1 parent 8b51d14 commit cf22b94
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .changelog/1281.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for hiding all fiat values
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
REACT_APP_SHOW_BUILD_BANNERS=true
# REACT_APP_FIXED_NETWORK=testnet
# REACT_APP_FIXED_LAYER=sapphire
REACT_APP_SHOW_FIAT_VALUES=true
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
REACT_APP_SHOW_BUILD_BANNERS=true
# REACT_APP_FIXED_NETWORK=testnet
# REACT_APP_FIXED_LAYER=sapphire
REACT_APP_SHOW_FIAT_VALUES=true
4 changes: 2 additions & 2 deletions src/app/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { AccountAvatar } from '../AccountAvatar'
import { RuntimeBalanceDisplay } from '../Balance/RuntimeBalanceDisplay'
import { calculateFiatValue } from '../Balance/hooks'
import { FiatMoneyAmount } from '../Balance/FiatMoneyAmount'
import { getFiatCurrencyForScope, getTokensForScope } from '../../../config'
import { getFiatCurrencyForScope, getTokensForScope, showFiatValues } from '../../../config'

type AccountProps = {
account?: RuntimeAccount
Expand Down Expand Up @@ -115,7 +115,7 @@ export const Account: FC<AccountProps> = ({ account, token, isLoading, tokenPric
<TokenPills account={account} tokens={account.evm_balances} />
</dd>

{!fiatValueInfo.loading && fiatValueInfo.hasValue && (
{showFiatValues && !fiatValueInfo.loading && fiatValueInfo.hasValue && (
<>
<dt>{t('common.fiatValue')}</dt>
<dd>
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ActiveAccounts } from './ActiveAccounts'
import { ChartDuration } from '../../utils/chart-utils'
import { useTranslation } from 'react-i18next'
import { useConstant } from '../../hooks/useConstant'
import { getTokensForScope } from '../../../config'
import { getTokensForScope, showFiatValues } from '../../../config'
import { getLayerLabels } from '../../utils/content'
import { TestnetFaucet } from './TestnetFaucet'
import { SearchScope } from '../../../types/searchScope'
Expand Down Expand Up @@ -53,7 +53,7 @@ export const ParaTimeSnapshot: FC<{ scope: SearchScope }> = ({ scope }) => {
<Nodes scope={scope} />
</StyledGrid>
<StyledGrid item xs={22} md={5}>
{!mainToken.free && <TokenPriceCard token={mainToken} />}
{showFiatValues && !mainToken.free && <TokenPriceCard token={mainToken} />}
{faucetLink && <TestnetFaucet network={scope.network} layer={scope.layer} ticker={mainTicker} />}
</StyledGrid>
</Snapshot>
Expand Down
5 changes: 3 additions & 2 deletions src/app/pages/RuntimeTransactionDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { LongDataDisplay } from '../../components/LongDataDisplay'
import { getPreciseNumberFormat } from '../../../locales/getPreciseNumberFormat'
import { base64ToHex } from '../../utils/helpers'
import { DappBanner } from '../../components/DappBanner'
import { getFiatCurrencyForScope } from '../../../config'
import { getFiatCurrencyForScope, showFiatValues } from '../../../config'

type TransactionSelectionResult = {
wantedTransaction?: RuntimeTransaction
Expand Down Expand Up @@ -327,7 +327,8 @@ export const RuntimeTransactionDetailView: FC<{
: t('common.missing')}
</dd>

{transaction.amount !== undefined &&
{showFiatValues &&
transaction.amount !== undefined &&
!!tokenPriceInfo &&
!tokenPriceInfo.isLoading &&
!tokenPriceInfo.isFree &&
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,5 @@ export const getTokensForScope = (scope: SearchScope | undefined): NativeTokenIn

export const getFiatCurrencyForScope = (scope: SearchScope | undefined) =>
(scope ? paraTimesConfig[scope.layer]?.[scope.network]?.fiatCurrency : undefined) ?? 'usd'

export const showFiatValues = process.env.REACT_APP_SHOW_FIAT_VALUES === 'true'
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare global {
REACT_APP_STAGING_URLS?: string
REACT_APP_FIXED_NETWORK?: string
REACT_APP_FIXED_LAYER?: string
REACT_APP_SHOW_FIAT_VALUES?: string
}
}
}

0 comments on commit cf22b94

Please sign in to comment.