2020-03-25 04:15:05 +01:00
|
|
|
import { connect } from 'react-redux';
|
2022-02-01 21:23:48 +01:00
|
|
|
import { selectClaimForUri, selectClaimIsMine } from 'redux/selectors/claims';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { makeSelectPendingAmountByUri } from 'redux/selectors/wallet';
|
2020-10-23 21:55:19 +02:00
|
|
|
import { doOpenModal } from 'redux/actions/app';
|
2020-03-25 04:15:05 +01:00
|
|
|
import FileDescription from './view';
|
2022-02-01 21:23:48 +01:00
|
|
|
import { getClaimMetadata } from 'util/claim';
|
2020-03-25 04:15:05 +01:00
|
|
|
|
2021-11-11 05:48:10 +01:00
|
|
|
const select = (state, props) => {
|
2022-02-01 21:23:48 +01:00
|
|
|
const { uri } = props;
|
|
|
|
|
|
|
|
const pendingAmount = makeSelectPendingAmountByUri(uri)(state);
|
|
|
|
|
|
|
|
const claim = selectClaimForUri(state, uri);
|
|
|
|
const metadata = getClaimMetadata(claim);
|
|
|
|
const description = metadata && metadata.description;
|
|
|
|
const amount = claim ? parseFloat(claim.amount) + parseFloat(pendingAmount || claim.meta.support_amount) : 0;
|
|
|
|
const hasSupport = claim && claim.meta && claim.meta.support_amount && Number(claim.meta.support_amount) > 0;
|
|
|
|
|
|
|
|
const isEmpty = !claim || !metadata;
|
2021-11-11 05:48:10 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
2022-02-01 21:23:48 +01:00
|
|
|
description,
|
|
|
|
amount,
|
|
|
|
hasSupport,
|
|
|
|
isEmpty,
|
2021-11-11 05:48:10 +01:00
|
|
|
};
|
|
|
|
};
|
2020-03-25 04:15:05 +01:00
|
|
|
|
2022-02-01 21:23:48 +01:00
|
|
|
const perform = {
|
2020-10-23 21:55:19 +02:00
|
|
|
doOpenModal,
|
2022-02-01 21:23:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(select, perform)(FileDescription);
|