feat: show no arbitrator warning in offer list (#360)
This commit is contained in:
parent
138cb26065
commit
8808fb7f56
|
@ -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;
|
|
@ -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} → {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>);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue