Skip to content

Commit

Permalink
fix: pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
devchenyan committed Sep 7, 2023
1 parent e1894a6 commit 2597a24
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 405 deletions.
27 changes: 21 additions & 6 deletions packages/neuron-ui/src/components/AddressBook/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { useTranslation } from 'react-i18next'
import { useState as useGlobalState, useDispatch } from 'states'
import Dialog from 'widgets/Dialog'
import CopyZone from 'widgets/CopyZone'
import { Copy } from 'widgets/Icons/icon'
import { ReactComponent as Edit } from 'widgets/Icons/Edit.svg'
import Table, { TableProps } from 'widgets/Table'
import { Copy, Edit } from 'widgets/Icons/icon'
import Table, { TableProps, SortType } from 'widgets/Table'
import { shannonToCKBFormatter, useLocalDescription } from 'utils'
import { HIDE_BALANCE } from 'utils/const'
import Tooltip from 'widgets/Tooltip'
Expand All @@ -16,7 +15,7 @@ const AddressBook = ({ onClose }: { onClose?: () => void }) => {
const [t] = useTranslation()
const { addresses, id: walletId } = wallet

const [tabIdx, setTabIdx] = useState('0')
const [tabIdx, setTabIdx] = useState<string>('0')
const onTabClick = (e: React.SyntheticEvent<HTMLDivElement, MouseEvent>) => {
const {
dataset: { idx },
Expand Down Expand Up @@ -135,15 +134,31 @@ const AddressBook = ({ onClose }: { onClose?: () => void }) => {
</CopyZone>
)
},
sorter: (a: State.Address, b: State.Address) => Number(a.balance) - Number(b.balance),
sorter: (a: State.Address, b: State.Address, type: SortType) => {
if (type === SortType.Increase) {
return Number(a.balance) - Number(b.balance)
}
if (type === SortType.Decrease) {
return Number(b.balance) - Number(a.balance)
}
return 0
},
},
{
title: t('addresses.transactions'),
dataIndex: 'txCount',
align: 'center',
className: styles.txCount,
width: '100px',
sorter: (a: State.Address, b: State.Address) => a.txCount - b.txCount,
sorter: (a: State.Address, b: State.Address, type: SortType) => {
if (type === SortType.Increase) {
return Number(a.txCount) - Number(b.txCount)
}
if (type === SortType.Decrease) {
return Number(b.txCount) - Number(a.txCount)
}
return 0
},
},
],
[t, localDescription]
Expand Down
7 changes: 5 additions & 2 deletions packages/neuron-ui/src/components/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ const Overview = () => {
<div className={styles.balance}>
<span className={styles.balanceTitle}>
{t('overview.balance')}
{showBalance && <EyesOpen onClick={onChangeShowBalance} className={styles.balanceIcon} />}
{!!showBalance || <EyesClose onClick={onChangeShowBalance} className={styles.balanceIcon} />}
{showBalance ? (
<EyesOpen onClick={onChangeShowBalance} className={styles.balanceIcon} />
) : (
<EyesClose onClick={onChangeShowBalance} className={styles.balanceIcon} />
)}
</span>
{showBalance ? (
<CopyZone content={shannonToCKBFormatter(balance, false, '')} className={styles.copyBalance}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const toLongAddr = (addr: string) => {
}
}

const verifyAddressEqual = (address: string, compared?: string) => {
if (!compared) {
const verifyAddressEqual = (source: string, target?: string) => {
if (!target) {
return false
}
if (address.length !== compared.length) {
return toLongAddr(address) === toLongAddr(compared)
if (source.length !== target.length) {
return toLongAddr(source) === toLongAddr(target)
}
return address === compared
return source === target
}

const VerifyHardwareAddress = ({ address, wallet }: VerifyHardwareAddressProps) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-ui/src/components/Send/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { List } from 'office-ui-fabric-react'
import { useNavigate } from 'react-router-dom'
import { useState as useGlobalState, useDispatch, appState } from 'states'
import SendMetaInfo from 'components/SendMetaInfo'
import SendFieldset from 'components/SendFieldset'
Expand All @@ -20,6 +19,7 @@ import {
validateOutputs,
useOutputErrors,
shannonToCKBFormatter,
useGoBack,
} from 'utils'
import { HIDE_BALANCE } from 'utils/const'

Expand All @@ -29,7 +29,7 @@ import styles from './send.module.scss'

const SendHeader = ({ balance }: { balance: string }) => {
const { t } = useTranslation()
const navigate = useNavigate()
const onBack = useGoBack()

const [showBalance, setShowBalance] = useState(true)
const onChangeShowBalance = useCallback(() => {
Expand All @@ -38,7 +38,7 @@ const SendHeader = ({ balance }: { balance: string }) => {

return (
<div className={styles.headerContainer}>
<GoBack className={styles.goBack} onClick={() => navigate(-1)} />
<GoBack className={styles.goBack} onClick={onBack} />
<p>{t('navbar.send')}</p>
<Button className={styles.btn} type="text" onClick={onChangeShowBalance}>
{showBalance ? <EyesOpen /> : <EyesClose />}
Expand Down
237 changes: 0 additions & 237 deletions packages/neuron-ui/src/components/VerifyHardwareAddress/index.tsx

This file was deleted.

Loading

0 comments on commit 2597a24

Please sign in to comment.