feat: show no arbitrator warning in offer list (#360)

This commit is contained in:
Richard Ramos 2019-07-09 10:08:40 -04:00 committed by GitHub
parent 138cb26065
commit 8808fb7f56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -4,16 +4,20 @@ import {zeroAddress} from '../../utils/address';
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faExclamationTriangle} from "@fortawesome/free-solid-svg-icons";
const NoArbitratorWarning = ({arbitrator}) => <Fragment>
const NoArbitratorWarning = ({arbitrator, label}) => <Fragment>
{arbitrator === zeroAddress && <span className="text-danger text-small pl-2">
<FontAwesomeIcon className="mr-2" icon={faExclamationTriangle} size="sm"/>
No arbitrator found. Disputes cannot be opened
{label}
</span>}
</Fragment>;
NoArbitratorWarning.defaultProps = {
label: "No arbitrator found. Disputes cannot be opened"
};
NoArbitratorWarning.propTypes = {
arbitrator: PropTypes.string
arbitrator: PropTypes.string,
label: PropTypes.string
};
export default NoArbitratorWarning;

View File

@ -7,7 +7,8 @@ import Identicon from "../UserInformation/Identicon";
import {truncateTwo} from '../../utils/numbers';
import {calculateEscrowPrice} from '../../utils/transaction';
import classnames from 'classnames';
import {addressCompare} from '../../utils/address';
import {addressCompare, zeroAddress} from '../../utils/address';
import NoArbitratorWarning from "../../components/NoArbitratorWarning";
const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
let user;
@ -26,6 +27,7 @@ const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
}
const isOwner = addressCompare(userAddress, owner);
let nbOffersArbitrator = 0;
let nbOffersNoArbitrator = 0;
return (<Row className="border bg-white rounded p-3 mr-0 ml-0 mb-2" tag={Link} to={`/profile/${owner}`}>
<Col className="p-0">
@ -48,11 +50,11 @@ const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
<p className="m-0">
{offers.map((offer, index) => {
const isArbitrator = addressCompare(userAddress, offer.arbitrator);
if (isArbitrator) {
nbOffersArbitrator++;
}
const noArbitrator = addressCompare(offer.arbitrator, zeroAddress);
if (isArbitrator) nbOffersArbitrator++;
if (noArbitrator) nbOffersNoArbitrator++;
return <span key={`offer-${index}`}
className={classnames("border d-inline-block rounded mr-2 p-1 font-weight-medium text-small", {'text-warning': isArbitrator, 'text-black': !isArbitrator})}>
className={classnames("border d-inline-block rounded mr-2 p-1 font-weight-medium text-small", {'text-warning': isArbitrator, 'text-black': !isArbitrator && !noArbitrator, 'text-danger': noArbitrator})}>
{offer.token.symbol} &rarr; {truncateTwo(calculateEscrowPrice(offer, prices))} {offer.currency}
</span>;
})}
@ -60,6 +62,7 @@ const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
</Col>
</Row>}
{nbOffersArbitrator > 0 && <span className="text-warning text-small">You are an arbitrator on {nbOffersArbitrator} offer{nbOffersArbitrator > 1 && 's'}</span>}
{nbOffersNoArbitrator > 0 && <NoArbitratorWarning arbitrator={zeroAddress} label="Some offers do not have an arbitrator assigned" />}
</Col>
</Row>);
};