Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: render issue on detail view for transfers with execution propert… #182

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading