import React from 'react'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import { Tag, Popconfirm, Tooltip } from 'antd'; import UnitDisplay from 'components/UnitDisplay'; import { ONE_DAY } from 'utils/time'; import { formatTxExplorerUrl } from 'utils/formatters'; import { deleteContribution } from 'modules/users/actions'; import { UserContribution } from 'types'; import './ProfileContribution.less'; import { PROPOSAL_STAGE } from 'api/constants'; interface OwnProps { userId: number; contribution: UserContribution; showSendInstructions(contribution: UserContribution): void; } interface DispatchProps { deleteContribution: typeof deleteContribution; } type Props = OwnProps & DispatchProps; class ProfileContribution extends React.Component { render() { const { contribution } = this.props; const { proposal, private: isPrivate } = contribution; const isConfirmed = contribution.status === 'CONFIRMED'; const isExpired = (!isConfirmed && contribution.dateCreated < Date.now() / 1000 - ONE_DAY) || (proposal.stage === PROPOSAL_STAGE.CANCELED || proposal.stage === PROPOSAL_STAGE.FAILED); let tag; let actions: React.ReactNode; if (isConfirmed) { actions = ( View transaction ); } else if (isExpired) { tag = Expired; actions = ( <> Delete Contact support ); } else { tag = Pending; actions = ( this.props.showSendInstructions(contribution)}> View send instructions ); } const privateTag = isPrivate ? ( Other users will not be able to see that you made this contribution. } > Private ) : null; return (
{proposal.title} {privateTag} {tag}
{proposal.brief}
+
{actions}
); } private deleteContribution = () => { this.props.deleteContribution(this.props.userId, this.props.contribution.id); }; } export default connect<{}, DispatchProps, OwnProps, {}>( undefined, { deleteContribution, }, )(ProfileContribution);