2018-07-30 20:53:54 +02:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import classnames from 'classnames'
|
2018-09-09 01:18:26 +02:00
|
|
|
import Tooltip from '../tooltip-v2'
|
2018-08-24 01:44:38 +02:00
|
|
|
import {
|
|
|
|
UNAPPROVED_STATUS,
|
|
|
|
REJECTED_STATUS,
|
|
|
|
APPROVED_STATUS,
|
|
|
|
SIGNED_STATUS,
|
|
|
|
SUBMITTED_STATUS,
|
|
|
|
CONFIRMED_STATUS,
|
|
|
|
FAILED_STATUS,
|
|
|
|
DROPPED_STATUS,
|
2018-12-09 21:48:06 +01:00
|
|
|
CANCELLED_STATUS,
|
2018-08-24 01:44:38 +02:00
|
|
|
} from '../../constants/transactions'
|
2018-07-30 20:53:54 +02:00
|
|
|
|
|
|
|
const statusToClassNameHash = {
|
|
|
|
[UNAPPROVED_STATUS]: 'transaction-status--unapproved',
|
|
|
|
[REJECTED_STATUS]: 'transaction-status--rejected',
|
|
|
|
[APPROVED_STATUS]: 'transaction-status--approved',
|
|
|
|
[SIGNED_STATUS]: 'transaction-status--signed',
|
|
|
|
[SUBMITTED_STATUS]: 'transaction-status--submitted',
|
|
|
|
[CONFIRMED_STATUS]: 'transaction-status--confirmed',
|
|
|
|
[FAILED_STATUS]: 'transaction-status--failed',
|
|
|
|
[DROPPED_STATUS]: 'transaction-status--dropped',
|
2018-12-09 21:48:06 +01:00
|
|
|
[CANCELLED_STATUS]: 'transaction-status--failed',
|
2018-07-30 20:53:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const statusToTextHash = {
|
|
|
|
[SUBMITTED_STATUS]: 'pending',
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class TransactionStatus extends PureComponent {
|
2018-09-09 01:18:26 +02:00
|
|
|
static defaultProps = {
|
|
|
|
title: null,
|
|
|
|
}
|
|
|
|
|
2018-08-24 01:44:38 +02:00
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
2018-07-30 20:53:54 +02:00
|
|
|
static propTypes = {
|
2018-08-24 01:44:38 +02:00
|
|
|
statusKey: PropTypes.string,
|
2018-08-01 04:37:38 +02:00
|
|
|
className: PropTypes.string,
|
2018-09-09 01:18:26 +02:00
|
|
|
title: PropTypes.string,
|
2018-07-30 20:53:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2018-09-09 01:18:26 +02:00
|
|
|
const { className, statusKey, title } = this.props
|
2018-08-24 01:44:38 +02:00
|
|
|
const statusText = this.context.t(statusToTextHash[statusKey] || statusKey)
|
2018-07-30 20:53:54 +02:00
|
|
|
|
|
|
|
return (
|
2018-08-24 01:44:38 +02:00
|
|
|
<div className={classnames('transaction-status', className, statusToClassNameHash[statusKey])}>
|
2018-12-09 21:48:06 +01:00
|
|
|
<Tooltip
|
|
|
|
position="top"
|
|
|
|
title={title}
|
|
|
|
>
|
2018-09-09 01:18:26 +02:00
|
|
|
{ statusText }
|
|
|
|
</Tooltip>
|
2018-07-30 20:53:54 +02:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|