2019-01-30 09:59:15 -08:00
|
|
|
import React from 'react';
|
|
|
|
import moment from 'moment';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { Link } from 'react-router-dom';
|
2019-02-18 10:08:20 -08:00
|
|
|
import { Icon, Button, Affix, Tag } from 'antd';
|
2019-02-01 11:25:17 -08:00
|
|
|
import ExceptionPage from 'components/ExceptionPage';
|
2019-01-30 09:59:15 -08:00
|
|
|
import { fetchRfp } from 'modules/rfps/actions';
|
|
|
|
import { getRfp } from 'modules/rfps/selectors';
|
|
|
|
import { RFP } from 'types';
|
|
|
|
import { AppState } from 'store/reducers';
|
|
|
|
import Loader from 'components/Loader';
|
|
|
|
import Markdown from 'components/Markdown';
|
2019-02-01 11:13:30 -08:00
|
|
|
import ProposalCard from 'components/Proposals/ProposalCard';
|
2019-02-08 11:02:34 -08:00
|
|
|
import UnitDisplay from 'components/UnitDisplay';
|
2019-03-13 22:06:22 -07:00
|
|
|
import HeaderDetails from 'components/HeaderDetails';
|
2019-10-24 10:32:00 -07:00
|
|
|
import Like from 'components/Like';
|
2019-10-10 17:12:38 -07:00
|
|
|
import { RFP_STATUS } from 'api/constants';
|
2019-12-03 16:02:39 -08:00
|
|
|
import { formatUsd } from 'utils/formatters';
|
2019-01-30 09:59:15 -08:00
|
|
|
import './index.less';
|
|
|
|
|
|
|
|
interface OwnProps {
|
|
|
|
rfpId: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface StateProps {
|
|
|
|
rfp: RFP | undefined;
|
|
|
|
isFetchingRfps: AppState['rfps']['isFetchingRfps'];
|
|
|
|
fetchRfpsError: AppState['rfps']['fetchRfpsError'];
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DispatchProps {
|
|
|
|
fetchRfp: typeof fetchRfp;
|
|
|
|
}
|
|
|
|
|
|
|
|
type Props = OwnProps & StateProps & DispatchProps;
|
|
|
|
|
|
|
|
class RFPDetail extends React.Component<Props> {
|
|
|
|
componentDidMount() {
|
|
|
|
this.props.fetchRfp(this.props.rfpId);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { rfp, isFetchingRfps } = this.props;
|
|
|
|
|
|
|
|
// Optimistically render rfp if we have it, but are updating it
|
|
|
|
if (!rfp) {
|
|
|
|
if (isFetchingRfps) {
|
|
|
|
return <Loader size="large" />;
|
|
|
|
} else {
|
2019-02-01 11:25:17 -08:00
|
|
|
return <ExceptionPage code="404" desc="No request could be found" />;
|
2019-01-30 09:59:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-10 17:12:38 -07:00
|
|
|
const isLive = rfp.status === RFP_STATUS.LIVE;
|
2019-02-18 10:08:20 -08:00
|
|
|
const tags = [];
|
|
|
|
|
|
|
|
if (rfp.matching) {
|
|
|
|
tags.push(
|
|
|
|
<Tag key="matching" color="#1890ff">
|
|
|
|
x2 matching
|
|
|
|
</Tag>,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rfp.bounty) {
|
2019-12-03 16:02:39 -08:00
|
|
|
if (rfp.isVersionTwo) {
|
|
|
|
tags.push(
|
|
|
|
<Tag key="bounty" color="#CF8A00">
|
|
|
|
{formatUsd(rfp.bounty.toString(10))} bounty
|
|
|
|
</Tag>,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
tags.push(
|
|
|
|
<Tag key="bounty" color="#CF8A00">
|
|
|
|
<UnitDisplay value={rfp.bounty} symbol="ZEC" /> bounty
|
|
|
|
</Tag>,
|
|
|
|
);
|
|
|
|
}
|
2019-02-18 10:08:20 -08:00
|
|
|
}
|
|
|
|
|
2019-10-10 17:12:38 -07:00
|
|
|
if (!isLive) {
|
|
|
|
tags.push(
|
|
|
|
<Tag key="closed" color="#f5222d">
|
|
|
|
Closed
|
2019-10-16 20:43:20 -07:00
|
|
|
</Tag>,
|
2019-10-10 17:12:38 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-01-30 09:59:15 -08:00
|
|
|
return (
|
|
|
|
<div className="RFPDetail">
|
2019-03-13 22:06:22 -07:00
|
|
|
<HeaderDetails title={rfp.title} description={rfp.brief} />
|
2019-01-30 09:59:15 -08:00
|
|
|
<div className="RFPDetail-top">
|
|
|
|
<Link className="RFPDetail-top-back" to="/requests">
|
|
|
|
<Icon type="arrow-left" /> Back to Requests
|
|
|
|
</Link>
|
2019-02-18 10:08:20 -08:00
|
|
|
|
2019-01-30 09:59:15 -08:00
|
|
|
<div className="RFPDetail-top-date">
|
2019-02-08 11:02:34 -08:00
|
|
|
Opened {moment(rfp.dateOpened * 1000).format('LL')}
|
2019-01-30 09:59:15 -08:00
|
|
|
</div>
|
2019-10-24 10:32:00 -07:00
|
|
|
<Like rfp={rfp} />
|
2019-01-30 09:59:15 -08:00
|
|
|
</div>
|
2019-02-18 10:08:20 -08:00
|
|
|
|
2019-01-30 09:59:15 -08:00
|
|
|
<h1 className="RFPDetail-title">{rfp.title}</h1>
|
2019-02-18 10:08:20 -08:00
|
|
|
<div className="RFPDetail-tags">{tags}</div>
|
|
|
|
<p className="RFPDetail-brief">{rfp.brief}</p>
|
|
|
|
|
2019-01-30 09:59:15 -08:00
|
|
|
<Markdown className="RFPDetail-content" source={rfp.content} />
|
2019-02-08 11:02:34 -08:00
|
|
|
<div className="RFPDetail-rules">
|
|
|
|
<ul>
|
2019-12-03 16:02:39 -08:00
|
|
|
{rfp.bounty &&
|
|
|
|
rfp.isVersionTwo && (
|
|
|
|
<li>
|
|
|
|
Accepted proposals will be funded up to{' '}
|
|
|
|
<strong>{formatUsd(rfp.bounty.toString(10))}</strong> in ZEC
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
{rfp.bounty &&
|
|
|
|
!rfp.isVersionTwo && (
|
|
|
|
<li>
|
|
|
|
Accepted proposals will be funded up to{' '}
|
|
|
|
<strong>
|
|
|
|
<UnitDisplay value={rfp.bounty} symbol="ZEC" />
|
|
|
|
</strong>
|
|
|
|
</li>
|
|
|
|
)}
|
2019-02-08 11:02:34 -08:00
|
|
|
{rfp.matching && (
|
|
|
|
<li>
|
2019-02-15 09:46:50 -08:00
|
|
|
Contributions will have their <strong>funding matched</strong> by the
|
|
|
|
Zcash Foundation
|
2019-02-08 11:02:34 -08:00
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
{rfp.dateCloses && (
|
|
|
|
<li>
|
|
|
|
Proposal submissions end {moment(rfp.dateCloses * 1000).format('LL')}
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2019-02-01 11:13:30 -08:00
|
|
|
|
|
|
|
{!!rfp.acceptedProposals.length && (
|
|
|
|
<div className="RFPDetail-proposals">
|
|
|
|
<h2 className="RFPDetail-proposals-title">Accepted Proposals</h2>
|
|
|
|
{rfp.acceptedProposals.map(p => (
|
|
|
|
<ProposalCard key={p.proposalId} {...p} />
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2019-10-10 17:12:38 -07:00
|
|
|
{isLive && (
|
|
|
|
<div className="RFPDetail-submit">
|
|
|
|
<Affix offsetBottom={0}>
|
|
|
|
<div className="RFPDetail-submit-inner">
|
|
|
|
<span>Ready to take on this request?</span>{' '}
|
|
|
|
<Link to={`/create?rfp=${rfp.id}`}>
|
|
|
|
<Button
|
|
|
|
className="RFPDetail-submit-inner-button"
|
|
|
|
type="primary"
|
|
|
|
size="large"
|
|
|
|
>
|
|
|
|
Start a Proposal
|
|
|
|
<Icon type="right-circle" />
|
|
|
|
</Button>
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
</Affix>
|
|
|
|
</div>
|
|
|
|
)}
|
2019-01-30 09:59:15 -08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect<StateProps, DispatchProps, OwnProps, AppState>(
|
|
|
|
(state, ownProps) => ({
|
|
|
|
rfp: getRfp(state, ownProps.rfpId),
|
|
|
|
isFetchingRfps: state.rfps.isFetchingRfps,
|
|
|
|
fetchRfpsError: state.rfps.fetchRfpsError,
|
|
|
|
}),
|
|
|
|
{ fetchRfp },
|
|
|
|
)(RFPDetail);
|