Skip to content

Commit

Permalink
refactor: reuse HIDE_BALANCE constant
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteMinds committed May 4, 2023
1 parent b3547bf commit ae458f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 6 additions & 2 deletions packages/neuron-ui/src/components/NervosDAO/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import PageContainer from 'components/PageContainer'
import CopyZone from 'widgets/CopyZone'
import { ArrowNext, Deposit, EyesClose, EyesOpen, Tooltip } from 'widgets/Icons/icon'
import TableNoData from 'widgets/Icons/TableNoData.png'
import { HIDE_BALANCE } from 'utils/const'

import hooks from './hooks'
import styles from './nervosDAO.module.scss'
Expand Down Expand Up @@ -332,7 +333,8 @@ const NervosDAO = () => {
name={t('nervos-dao.copy-balance')}
className={styles.balance}
>
<span className={styles.number}>{isPrivacyMode ? '******' : shannonToCKBFormatter(`${free}`)}</span> CKB
<span className={styles.number}>{isPrivacyMode ? HIDE_BALANCE : shannonToCKBFormatter(`${free}`)}</span>{' '}
CKB
</CopyZone>
</div>
</div>
Expand All @@ -346,7 +348,9 @@ const NervosDAO = () => {
name={t('nervos-dao.copy-balance')}
className={styles.balance}
>
<span className={styles.number}>{isPrivacyMode ? '******' : shannonToCKBFormatter(`${locked}`)}</span>{' '}
<span className={styles.number}>
{isPrivacyMode ? HIDE_BALANCE : shannonToCKBFormatter(`${locked}`)}
</span>{' '}
CKB
</CopyZone>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { scriptToAddress } from '@nervosnetwork/ckb-sdk-utils'
import { onEnter } from 'utils/inputDevice'
import { EyesClose, EyesOpen } from 'widgets/Icons/icon'
import { MAINNET_TAG } from 'utils/const'
import { HIDE_BALANCE, MAINNET_TAG } from 'utils/const'
import ScriptTag from 'components/ScriptTag'
import LockInfoDialog from 'components/LockInfoDialog'
import { useState as useGlobalState } from 'states'
Expand Down Expand Up @@ -76,7 +76,7 @@ const TabsVariantWithCellsCard: FC<
</>
)}
</div>
<div>{`${isPrivacyMode ? '******' : capacity} CKB`}</div>
<div>{`${isPrivacyMode ? HIDE_BALANCE : capacity} CKB`}</div>
</div>
)
})}
Expand Down
7 changes: 4 additions & 3 deletions packages/neuron-ui/src/components/NervosDAORecord/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import CompensationPeriodTooltip from 'components/CompensationPeriodTooltip'
import { Clock } from 'widgets/Icons/icon'
import { Link } from 'react-router-dom'
import { HIDE_BALANCE } from 'utils/const'

import styles from './daoRecordRow.module.scss'
import hooks from './hooks'
Expand Down Expand Up @@ -209,18 +210,18 @@ export const DAORecord = ({
<div className={styles.container}>
<div className={styles.amountAndBadge}>
<CopyZone className={styles.amount} content={shannonToCKBFormatter(capacity, false, '')}>
{`${isPrivacyMode ? '******' : shannonToCKBFormatter(capacity)} CKB`}
{`${isPrivacyMode ? HIDE_BALANCE : shannonToCKBFormatter(capacity)} CKB`}
</CopyZone>
{badge}
</div>

<div className={styles.compensationAndAPC}>
<span className={styles.compensation}>
{CellStatus.Depositing !== cellStatus && compensation >= BigInt(0)
? `${isPrivacyMode ? '******' : `+${shannonToCKBFormatter(compensation.toString()).toString()}`} CKB`
? `${isPrivacyMode ? HIDE_BALANCE : `+${shannonToCKBFormatter(compensation.toString()).toString()}`} CKB`
: '- CKB'}
</span>
<span className={styles.apc}>{apc ? `APC ≈ ${isPrivacyMode ? '******' : `${apc}%`}` : `APC ≈ - %`}</span>
<span className={styles.apc}>{apc ? `APC ≈ ${isPrivacyMode ? HIDE_BALANCE : `${apc}%`}` : `APC ≈ - %`}</span>
</div>

{CellStatus.Completed === cellStatus ? (
Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-ui/src/stories/Table.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { ComponentStory } from '@storybook/react'
import Table from 'widgets/Table'
import { HIDE_BALANCE } from 'utils/const'

export default {
title: 'Table',
Expand Down Expand Up @@ -93,7 +94,7 @@ TableWithColumnRender.args = {
dataIndex: 'balance',
isBalance: true,
render(v: string, _idx, _item, showBalance) {
return <span style={{ color: v.includes('-') ? undefined : '#00C891' }}>{showBalance ? v : '******'}</span>
return <span style={{ color: v.includes('-') ? undefined : '#00C891' }}>{showBalance ? v : HIDE_BALANCE}</span>
},
},
],
Expand Down

0 comments on commit ae458f4

Please sign in to comment.