forked from nervosnetwork/ckb-explorer-frontend
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Chen Yu <[email protected]>
- Loading branch information
Showing
17 changed files
with
128 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ export enum TransactionLeapDirection { | |
NONE = 'none', | ||
IN = 'in', | ||
OUT = 'out', | ||
WITH_IN_BTC = 'with_in_btc', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 37 additions & 19 deletions
56
src/components/TransactionItem/TransactionRGBPPDigestModal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,49 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { useQuery } from '@tanstack/react-query' | ||
import { useMemo } from 'react' | ||
import styles from './styles.module.scss' | ||
import CloseIcon from '../../../assets/modal_close.png' | ||
import { TransactionRGBPPDigestContent } from './TransactionRGBPPDigestContent' | ||
import { explorerService } from '../../../services/ExplorerService' | ||
import { TransactionLeapDirection } from '../../RGBPP/types' | ||
|
||
const TransactionRGBPPDigestModal = ({ | ||
hash, | ||
leapDirection, | ||
onClickClose, | ||
}: { | ||
onClickClose: Function | ||
hash: string | ||
leapDirection: TransactionLeapDirection | ||
}) => { | ||
const TransactionRGBPPDigestModal = ({ hash, onClickClose }: { onClickClose: Function; hash: string }) => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<div className={styles.header}> | ||
<span className={styles.left}>{t('address.transaction_rgbpp_digest')}</span> | ||
<button onClick={() => onClickClose()} type="button" className={styles.buttonClose}> | ||
<img src={CloseIcon} alt="close icon" className={styles.closeIcon} /> | ||
</button> | ||
const { data, isFetched } = useQuery(['rgb-digest', hash], () => explorerService.api.fetchRGBDigest(hash)) | ||
|
||
const direction = useMemo(() => { | ||
switch (data?.data.leapDirection) { | ||
case 'in': | ||
return TransactionLeapDirection.IN | ||
case 'leapoutBTC': | ||
return TransactionLeapDirection.OUT | ||
case 'withinBTC': | ||
return TransactionLeapDirection.WITH_IN_BTC | ||
default: | ||
return TransactionLeapDirection.NONE | ||
} | ||
}, [data]) | ||
|
||
if (isFetched && data?.data) { | ||
return ( | ||
<div className={styles.container}> | ||
<div className={styles.header}> | ||
<div className={styles.left}> | ||
<span>{t('address.transaction_rgbpp_digest')}</span> | ||
{direction !== TransactionLeapDirection.NONE && ( | ||
<span className={styles.leap}>{t(`address.leap_${direction}`)}</span> | ||
)} | ||
</div> | ||
<button onClick={() => onClickClose()} type="button" className={styles.buttonClose}> | ||
<img src={CloseIcon} alt="close icon" className={styles.closeIcon} /> | ||
</button> | ||
</div> | ||
<TransactionRGBPPDigestContent hash={hash} digest={data?.data} isFetched={isFetched} /> | ||
</div> | ||
<TransactionRGBPPDigestContent leapDirection={leapDirection} hash={hash} /> | ||
</div> | ||
) | ||
) | ||
} | ||
return null | ||
} | ||
|
||
export default TransactionRGBPPDigestModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.