Skip to content

Commit

Permalink
fix: render issue on detail view for transfers with execution propert…
Browse files Browse the repository at this point in the history
…y as null (#182)
  • Loading branch information
wainola authored Jul 5, 2024
1 parent 7cc589f commit 040c9c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
36 changes: 20 additions & 16 deletions src/pages/DetailView/DetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function DetailView() {
<span className={classes.detailsInnerContentTitle}>Source transaction hash:</span>
<span className={classes.detailsInnerContent}>
<Link
to={txHashLinks(fromDomainInfo!.type, transfer?.deposit?.txHash!, fromDomainExplorerUrl!.url)}
to={txHashLinks(fromDomainInfo!.type, fromDomainExplorerUrl!.url, transfer?.deposit?.txHash!)}
style={{ color: "black" }}
target="_blank"
>
Expand All @@ -139,26 +139,30 @@ export default function DetailView() {
<span className={classes.detailsInnerContentTitle}>Destination transaction hash:</span>
<span className={classes.detailsInnerContent}>
<Link
to={txHashLinks(toDomainInfo!.type, transfer?.execution?.txHash!, toDomainExplorerUrl!.url)}
to={txHashLinks(toDomainInfo!.type, toDomainExplorerUrl!.url, transfer?.execution?.txHash!)}
style={{ color: "black" }}
target="_blank"
>
{transfer?.execution && transfer?.execution?.txHash}
</Link>
<span
className={classes.copyIcon}
onClick={() => {
void navigator.clipboard?.writeText(transfer?.execution?.txHash!)
dispatcher({
type: "set_clipboard_message_t2",
payload: "Copied to clipboard!",
})
}}
>
<Tooltip title={state.clipboardMessageT2} placement="top" arrow>
<ContentCopyIcon fontSize="small" />
</Tooltip>
</span>
{transfer?.execution ? (
<span
className={classes.copyIcon}
onClick={() => {
void navigator.clipboard?.writeText(transfer?.execution?.txHash!)
dispatcher({
type: "set_clipboard_message_t2",
payload: "Copied to clipboard!",
})
}}
>
<Tooltip title={state.clipboardMessageT2} placement="top" arrow>
<ContentCopyIcon fontSize="small" />
</Tooltip>
</span>
) : (
<span>Pending proposal execution</span>
)}
</span>
</div>
<div className={classes.detailsContainer}>
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ export const renderFormatedConvertedAmount = (type: ResourceTypes, usdValue: num
return ""
}

export const txHashLinks = (type: DomainTypes, txHash: string, domainExplorerUrl: string): string => {
export const txHashLinks = (type: DomainTypes, domainExplorerUrl: string, txHash?: string): string => {
switch (type) {
case DomainTypes.EVM:
return `${domainExplorerUrl}/tx/${txHash}`
case DomainTypes.SUBSTRATE:
return `${domainExplorerUrl}/${txHash.split("-")[0]}`
return `${domainExplorerUrl}/${txHash?.split("-")[0] || ""}`
default:
return ""
}
Expand Down

0 comments on commit 040c9c3

Please sign in to comment.