diff --git a/frontend/client/api/api.ts b/frontend/client/api/api.ts index cecd9727..136ff2ee 100644 --- a/frontend/client/api/api.ts +++ b/frontend/client/api/api.ts @@ -220,6 +220,7 @@ export function postProposalContribution( }); } + export function postProposalComment(payload: { proposalId: number; parentCommentId?: number; @@ -232,3 +233,10 @@ export function postProposalComment(payload: { export function deleteProposalContribution(contributionId: string | number) { return axios.delete(`/api/v1/proposals/contribution/${contributionId}`); } + +export function getProposalContribution( + proposalId: number, + contributionId: number, +): Promise<{ data: ContributionWithAddresses }> { + return axios.get(`/api/v1/proposals/${proposalId}/contributions/${contributionId}`); +} diff --git a/frontend/client/components/ContributionModal/PaymentInfo.less b/frontend/client/components/ContributionModal/PaymentInfo.less index 2bbeb54c..de120fe8 100644 --- a/frontend/client/components/ContributionModal/PaymentInfo.less +++ b/frontend/client/components/ContributionModal/PaymentInfo.less @@ -19,6 +19,7 @@ border-bottom: 1px solid rgba(#000, 0.06); &-qr { + position: relative; padding: 0.5rem; margin-right: 1rem; border-radius: 4px; @@ -28,6 +29,16 @@ canvas { display: block; } + &.is-loading canvas { + opacity: 0; + } + + .ant-spin { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } } &-info { diff --git a/frontend/client/components/ContributionModal/PaymentInfo.tsx b/frontend/client/components/ContributionModal/PaymentInfo.tsx index 52d010b7..03a4cef4 100644 --- a/frontend/client/components/ContributionModal/PaymentInfo.tsx +++ b/frontend/client/components/ContributionModal/PaymentInfo.tsx @@ -67,8 +67,13 @@ export default class PaymentInfo extends React.Component {
-
- {uri ? : } +
+ + + + {!uri && }
{ }; componentWillUpdate(nextProps: Props) { - const { isVisible, proposalId } = nextProps - if (isVisible && this.props.isVisible !== isVisible) { - this.fetchAddresses(proposalId); - } - else if (proposalId !== this.props.proposalId) { - this.fetchAddresses(proposalId); + const { isVisible, proposalId, contributionId } = nextProps; + // When modal is opened and proposalId is provided or changed + if (isVisible && proposalId) { + if ( + this.props.isVisible !== isVisible || + proposalId !== this.props.proposalId + ) { + this.fetchAddresses(proposalId, contributionId); + } } + } render() { - const { isVisible, handleClose } = this.props; + const { isVisible, handleClose, hasNoButtons } = this.props; const { hasSent, contribution, error } = this.state; let content; @@ -68,11 +74,12 @@ export default class ContributionModal extends React.Component { {content} @@ -80,12 +87,20 @@ export default class ContributionModal extends React.Component { ); } - private async fetchAddresses(proposalId: number) { + private async fetchAddresses( + proposalId: number, + contributionId?: number, + ) { try { - const res = await postProposalContribution( - proposalId, - this.props.amount || '0', - ); + let res; + if (contributionId) { + res = await getProposalContribution(proposalId, contributionId); + } else { + res = await postProposalContribution( + proposalId, + this.props.amount || '0', + ); + } this.setState({ contribution: res.data }); } catch(err) { this.setState({ error: err.message }); diff --git a/frontend/client/components/Profile/ProfileContribution.tsx b/frontend/client/components/Profile/ProfileContribution.tsx index e8f9d789..1fb97adc 100644 --- a/frontend/client/components/Profile/ProfileContribution.tsx +++ b/frontend/client/components/Profile/ProfileContribution.tsx @@ -12,6 +12,7 @@ import './ProfileContribution.less'; interface OwnProps { userId: number; contribution: UserContribution; + showSendInstructions(contribution: UserContribution): void; } interface DispatchProps { @@ -30,7 +31,6 @@ class ProfileContribution extends React.Component { let tag; let actions: React.ReactNode; if (isConfirmed) { - // TODO: Link to block explorer actions = ( { > Delete - Contact support + Contact support ; } else { tag = Pending; - // TODO: Show ContributionModal - actions = View instructions; + actions = ( + this.props.showSendInstructions(contribution)}> + View send instructions + + ); } return ( diff --git a/frontend/client/components/Profile/index.tsx b/frontend/client/components/Profile/index.tsx index 7b62dbd0..7ca0af2a 100644 --- a/frontend/client/components/Profile/index.tsx +++ b/frontend/client/components/Profile/index.tsx @@ -21,7 +21,9 @@ import ProfileComment from './ProfileComment'; import ProfileInvite from './ProfileInvite'; import Placeholder from 'components/Placeholder'; import Exception from 'pages/exception'; +import ContributionModal from 'components/ContributionModal'; import './style.less'; +import { UserContribution } from 'types'; interface StateProps { usersMap: AppState['users']['map']; @@ -35,7 +37,15 @@ interface DispatchProps { type Props = RouteComponentProps & StateProps & DispatchProps; -class Profile extends React.Component { +interface State { + activeContribution: UserContribution | null; +} + +class Profile extends React.Component { + state: State = { + activeContribution: null, + }; + componentDidMount() { this.fetchData(); } @@ -50,6 +60,8 @@ class Profile extends React.Component { render() { const userLookupParam = this.props.match.params.id; const { authUser, match } = this.props; + const { activeContribution } = this.state; + if (!userLookupParam) { if (authUser && authUser.userid) { return ; @@ -128,7 +140,12 @@ class Profile extends React.Component {
{noneFunded && } {contributions.map(c => ( - + ))}
@@ -160,9 +177,20 @@ class Profile extends React.Component { )} + +
); } + private fetchData() { const { match } = this.props; const userLookupId = match.params.id; @@ -171,6 +199,9 @@ class Profile extends React.Component { this.props.fetchUserInvites(userLookupId); } } + + private openContributionModal = (c: UserContribution) => this.setState({ activeContribution: c }); + private closeContributionModal = () => this.setState({ activeContribution: null }); } const TabTitle = (disp: string, count: number) => ( diff --git a/frontend/stories/Proposal.story.tsx b/frontend/stories/Proposal.story.tsx index 41e85a6f..620d7413 100644 --- a/frontend/stories/Proposal.story.tsx +++ b/frontend/stories/Proposal.story.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import { storiesOf } from '@storybook/react'; import { ProposalCampaignBlock } from 'components/Proposal/CampaignBlock'; -import Contributors from 'components/Proposal/Contributors'; import 'styles/style.less'; import 'components/Proposal/style.less'; @@ -53,9 +52,4 @@ storiesOf('Proposal', module)
- )) - .add('Contributors', () => ( -
- -
)); diff --git a/frontend/types/contribution.ts b/frontend/types/contribution.ts index be98d1fa..e79a143b 100644 --- a/frontend/types/contribution.ts +++ b/frontend/types/contribution.ts @@ -2,7 +2,7 @@ import { Zat } from 'utils/units'; import { Proposal, User } from 'types'; export interface Contribution { - id: string; + id: number; txId: string; amount: string; dateCreated: number;