Skip to content

Commit

Permalink
Add tooltip to TransactionStatusIcon if withText=false
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Jun 21, 2023
1 parent 93413bd commit 9d80a6a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions .changelog/577.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add tooltip with error message to transaction status icons on lists
44 changes: 26 additions & 18 deletions src/app/components/TransactionStatusIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { styled } from '@mui/material/styles'
import { COLORS } from '../../../styles/theme/colors'
import HelpIcon from '@mui/icons-material/Help'
import { TxError } from '../../../oasis-indexer/api'
import Tooltip from '@mui/material/Tooltip'

type TxStatus = 'unknown' | 'success' | 'failure'

Expand Down Expand Up @@ -80,23 +81,30 @@ export const TransactionStatusIcon: FC<TransactionStatusIconProps> = ({ success,
success: t('common.success'),
failure: t('common.failed'),
}
const errorMessage = error ? `${error.message} (${t('errors.code')} ${error.code})` : undefined

return (
<>
<StyledBox success={success} error={error} withText={withText}>
{withText && (
<span>
{statusLabel[status]}
&nbsp;
</span>
)}
{statusIcon[status]}
</StyledBox>
{withText && error && (
<ErrorBox>
{error.message} ({t('errors.code')} {error.code})
</ErrorBox>
)}
</>
)
if (withText) {
return (
<>
<StyledBox success={success} error={error} withText={withText}>
{statusLabel[status]}
&nbsp;
{statusIcon[status]}
</StyledBox>
{error && <ErrorBox>{errorMessage}</ErrorBox>}
</>
)
} else {
return (
<Tooltip
arrow
placement="top"
title={errorMessage ? `${statusLabel[status]}: ${errorMessage}` : statusLabel[status]}
>
<StyledBox success={success} error={error} withText={withText}>
{statusIcon[status]}
</StyledBox>
</Tooltip>
)
}
}

0 comments on commit 9d80a6a

Please sign in to comment.