import React from 'react'; import { view } from 'react-easy-state'; import { RouteComponentProps, withRouter } from 'react-router'; import { Alert, Button, Card, Col, Collapse, message, Row } from 'antd'; import TextArea from 'antd/lib/input/TextArea'; import store from 'src/store'; import { formatDateSeconds } from 'util/time'; import { CCR_STATUS } from 'src/types'; import Back from 'components/Back'; import Markdown from 'components/Markdown'; import FeedbackModal from '../FeedbackModal'; import './index.less'; import { Link } from 'react-router-dom'; type Props = RouteComponentProps; const STATE = { paidTxId: '', showCancelAndRefundPopover: false, showChangeToAcceptedWithFundingPopover: false, }; type State = typeof STATE; class CCRDetailNaked extends React.Component { state = STATE; rejectInput: null | TextArea = null; componentDidMount() { this.loadDetail(); } render() { const id = this.getIdFromQuery(); const { ccrDetail: c, ccrDetailFetching } = store; if (!c || (c && c.ccrId !== id) || ccrDetailFetching) { return 'loading ccr...'; } const renderApproved = () => c.status === CCR_STATUS.APPROVED && ( ); const renderReview = () => c.status === CCR_STATUS.PENDING && (

Please review this Community Created Request and render your judgment.

} /> ); const renderRejected = () => c.status === CCR_STATUS.REJECTED && (

This CCR has changes requested. The team will be able to re-submit it for approval should they desire to do so.

Reason:
{c.rejectReason} } /> ); const renderDeetItem = (name: string, val: any) => (
{name} {val}  
); return (

{c.title}

{/* MAIN */} {renderApproved()} {renderReview()} {renderRejected()} {c.brief}
{JSON.stringify(c, null, 4)}
{/* RIGHT SIDE */} {c.rfp && ( This CCR has been accepted and is instantiated as an RFP{' '} here. } type="info" showIcon /> )} {/* DETAILS */} {renderDeetItem('id', c.ccrId)} {renderDeetItem('created', formatDateSeconds(c.dateCreated))} {renderDeetItem( 'published', c.datePublished ? formatDateSeconds(c.datePublished) : 'n/a', )} {renderDeetItem( 'status', c.status === CCR_STATUS.LIVE ? 'Accepted/Generated RFP' : c.status, )} {renderDeetItem('target', c.target)}
{c.author.displayName}
); } private getIdFromQuery = () => { return Number(this.props.match.params.id); }; private loadDetail = () => { store.fetchCCRDetail(this.getIdFromQuery()); }; private handleApprove = async () => { await store.approveCCR(true); if (store.ccrCreatedRFPId) { message.success('Successfully created RFP from CCR!', 1); setTimeout( () => this.props.history.replace(`/rfps/${store.ccrCreatedRFPId}/edit`), 1500, ); } }; private handleReject = async (reason: string) => { await store.approveCCR(false, reason); message.info('CCR changes requested'); }; private handleRejectPermanently = async (rejectReason: string) => { await store.rejectPermanentlyCcr(rejectReason); message.info('CCR rejected permanently'); }; } const CCRDetail = withRouter(view(CCRDetailNaked)); export default CCRDetail;