Skip to content

Commit

Permalink
Use a link for opening TX in explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Nov 30, 2023
1 parent 787ecfd commit abc9f96
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/pages/Transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ export const Transaction: FC = () => {
init()
}, [getTransaction, navigate, txHash])

const handleNavigateToExplorer = () => {
if (explorerBaseUrl && txHash) {
const txUrl = StringUtils.getTransactionUrl(explorerBaseUrl, txHash)
window.open(txUrl, '_blank', 'noopener,noreferrer')
}
}
const txUrl = explorerBaseUrl && txHash ? StringUtils.getTransactionUrl(explorerBaseUrl, txHash) : undefined

const handleNavigateBack = () => {
navigate('/wrapper')
Expand Down Expand Up @@ -92,11 +87,13 @@ export const Transaction: FC = () => {
{type === TransactionType.Rose && <b>&nbsp;{amount} ROSE</b>}
</h3>

{explorerBaseUrl && txHash && (
<Button className={classes.openInExplorerBtn} onClick={handleNavigateToExplorer} fullWidth>
View on explorer
<OpenInNewIcon />
</Button>
{txUrl && (
<a href={txUrl} target="_blank" rel="noopener noreferrer">
<Button className={classes.openInExplorerBtn} fullWidth>
View on explorer
<OpenInNewIcon />
</Button>
</a>
)}
<Button variant="secondary" onClick={handleNavigateBack} fullWidth>
Close
Expand Down

0 comments on commit abc9f96

Please # to comment.