2021-07-14 15:42:10 +02:00
|
|
|
import React, { useContext } from 'react';
|
2021-06-24 01:39:44 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2021-08-06 01:59:58 +02:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
|
|
import { getIsGasEstimatesLoading } from '../../../ducks/metamask/metamask';
|
|
|
|
import { getGasLoadingAnimationIsShowing } from '../../../ducks/app/app';
|
2021-07-14 15:42:10 +02:00
|
|
|
|
|
|
|
import { I18nContext } from '../../../contexts/i18n';
|
|
|
|
|
2021-06-24 01:39:44 +02:00
|
|
|
import TransactionDetailItem from '../transaction-detail-item/transaction-detail-item.component';
|
2021-08-06 01:59:58 +02:00
|
|
|
import LoadingHeartBeat from '../../ui/loading-heartbeat';
|
2021-06-24 01:39:44 +02:00
|
|
|
|
2021-07-14 15:42:10 +02:00
|
|
|
export default function TransactionDetail({ rows = [], onEdit }) {
|
|
|
|
const t = useContext(I18nContext);
|
2021-08-06 01:59:58 +02:00
|
|
|
const isGasEstimatesLoading = useSelector(getIsGasEstimatesLoading);
|
|
|
|
const gasLoadingAnimationIsShowing = useSelector(
|
|
|
|
getGasLoadingAnimationIsShowing,
|
|
|
|
);
|
2021-07-14 15:42:10 +02:00
|
|
|
|
|
|
|
return (
|
2021-07-26 17:24:44 +02:00
|
|
|
<div className="transaction-detail">
|
2021-08-06 01:59:58 +02:00
|
|
|
{process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />}
|
2021-07-14 15:42:10 +02:00
|
|
|
{onEdit && (
|
|
|
|
<div className="transaction-detail-edit">
|
2021-08-06 01:59:58 +02:00
|
|
|
<button
|
|
|
|
onClick={onEdit}
|
|
|
|
disabled={isGasEstimatesLoading || gasLoadingAnimationIsShowing}
|
|
|
|
>
|
|
|
|
{t('edit')}
|
|
|
|
</button>
|
2021-07-14 15:42:10 +02:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className="transaction-detail-rows">{rows}</div>
|
|
|
|
</div>
|
|
|
|
);
|
2021-06-24 01:39:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TransactionDetail.propTypes = {
|
2021-07-14 15:42:10 +02:00
|
|
|
rows: PropTypes.arrayOf(TransactionDetailItem).isRequired,
|
|
|
|
onEdit: PropTypes.func,
|
2021-06-24 01:39:44 +02:00
|
|
|
};
|