You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
|
import { findLastIndex } from 'lodash';
|
||
4 years ago
|
import {
|
||
|
conversionRateSelector,
|
||
|
getNativeCurrency,
|
||
|
getRpcPrefsForCurrentProvider,
|
||
|
} from '../../../selectors';
|
||
4 years ago
|
import TransactionActivityLog from './transaction-activity-log.component';
|
||
|
import { combineTransactionHistories } from './transaction-activity-log.util';
|
||
6 years ago
|
import {
|
||
|
TRANSACTION_RESUBMITTED_EVENT,
|
||
|
TRANSACTION_CANCEL_ATTEMPTED_EVENT,
|
||
4 years ago
|
} from './transaction-activity-log.constants';
|
||
6 years ago
|
|
||
4 years ago
|
const matchesEventKey = (matchEventKey) => ({ eventKey }) =>
|
||
4 years ago
|
eventKey === matchEventKey;
|
||
6 years ago
|
|
||
5 years ago
|
const mapStateToProps = (state) => {
|
||
6 years ago
|
return {
|
||
|
conversionRate: conversionRateSelector(state),
|
||
6 years ago
|
nativeCurrency: getNativeCurrency(state),
|
||
4 years ago
|
rpcPrefs: getRpcPrefsForCurrentProvider(state),
|
||
4 years ago
|
};
|
||
|
};
|
||
6 years ago
|
|
||
6 years ago
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||
|
const {
|
||
4 years ago
|
transactionGroup: { transactions = [], primaryTransaction } = {},
|
||
6 years ago
|
...restOwnProps
|
||
4 years ago
|
} = ownProps;
|
||
6 years ago
|
|
||
4 years ago
|
const activities = combineTransactionHistories(transactions);
|
||
4 years ago
|
const inlineRetryIndex = findLastIndex(
|
||
|
activities,
|
||
|
matchesEventKey(TRANSACTION_RESUBMITTED_EVENT),
|
||
4 years ago
|
);
|
||
4 years ago
|
const inlineCancelIndex = findLastIndex(
|
||
|
activities,
|
||
|
matchesEventKey(TRANSACTION_CANCEL_ATTEMPTED_EVENT),
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
|
return {
|
||
|
...stateProps,
|
||
|
...dispatchProps,
|
||
|
...restOwnProps,
|
||
|
activities,
|
||
|
inlineRetryIndex,
|
||
|
inlineCancelIndex,
|
||
|
primaryTransaction,
|
||
4 years ago
|
};
|
||
|
};
|
||
6 years ago
|
|
||
4 years ago
|
export default connect(
|
||
|
mapStateToProps,
|
||
|
null,
|
||
|
mergeProps,
|
||
4 years ago
|
)(TransactionActivityLog);
|