import React from 'react'; import { connect } from 'react-redux'; import { Input, Form, Alert, Popconfirm, message, Radio } from 'antd'; import { RadioChangeEvent } from 'antd/lib/radio'; import { ProposalDraft, RFP } from 'types'; import { getCreateErrors } from 'modules/create/utils'; import { Link } from 'react-router-dom'; import { unlinkProposalRFP } from 'modules/create/actions'; import { AppState } from 'store/reducers'; interface OwnProps { proposalId: number; initialState?: Partial; updateForm(form: Partial): void; } interface StateProps { isUnlinkingProposalRFP: AppState['create']['isUnlinkingProposalRFP']; unlinkProposalRFPError: AppState['create']['unlinkProposalRFPError']; } interface DispatchProps { unlinkProposalRFP: typeof unlinkProposalRFP; } type Props = OwnProps & StateProps & DispatchProps; interface State extends Partial { title: string; brief: string; target: string; rfp?: RFP; } class CreateFlowBasics extends React.Component { constructor(props: Props) { super(props); this.state = { title: '', brief: '', target: '', ...(props.initialState || {}), }; } componentDidUpdate(prevProps: Props) { const { unlinkProposalRFPError, isUnlinkingProposalRFP } = this.props; if ( unlinkProposalRFPError && unlinkProposalRFPError !== prevProps.unlinkProposalRFPError ) { console.error('Failed to unlink request:', unlinkProposalRFPError); message.error('Failed to unlink request'); } else if (!isUnlinkingProposalRFP && prevProps.isUnlinkingProposalRFP) { this.setState({ rfp: undefined }); message.success('Unlinked proposal from request'); } } render() { const { isUnlinkingProposalRFP } = this.props; const { title, brief, target, rfp, rfpOptIn } = this.state; const errors = getCreateErrors(this.state, true); // Don't show target error at zero since it defaults to that // Error just shows up at the end to prevent submission if (target === '0') { errors.target = undefined; } const rfpOptInRequired = rfp && (rfp.matching || (rfp.bounty && parseFloat(rfp.bounty.toString()) > 0)); return (
{rfp && ( This proposal is for the open request{' '} {rfp.title} . If you didn’t mean to do this, or want to unlink it,{' '} click here {' '} to do so. } showIcon /> )} {rfpOptInRequired && (
This RFP offers either a bounty or matching. This will require ZFGrants to fulfill{' '} KYC {' '} due dilligence. In the event your proposal is successful, you will need to provide identifying information to ZFGrants. Yes, I am willing to provide KYC information No, I do not wish to provide KYC information and understand I will not receive any matching or bounty funds from ZFGrants
} /> )} ); } private handleInputChange = ( event: React.ChangeEvent, ) => { const { value, name } = event.currentTarget; this.setState({ [name]: value } as any, () => { this.props.updateForm(this.state); }); }; private handleRfpOptIn = (e: RadioChangeEvent) => { this.setState({ rfpOptIn: e.target.value }, () => { this.props.updateForm(this.state); }); }; private unlinkRfp = () => { this.props.unlinkProposalRFP(this.props.proposalId); }; } export default connect( state => ({ isUnlinkingProposalRFP: state.create.isUnlinkingProposalRFP, unlinkProposalRFPError: state.create.unlinkProposalRFPError, }), { unlinkProposalRFP }, )(CreateFlowBasics);