fix: offer mismatch in offer list (#262)
* fix: display all offers (even if you are an arbitrator) * fix: disable offers where the user is an arbitrator
This commit is contained in:
parent
36b31f43bb
commit
0193a25bd0
|
@ -12,18 +12,24 @@ import {addressCompare} from '../../utils/address';
|
||||||
const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
|
const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
|
||||||
let user;
|
let user;
|
||||||
let owner;
|
let owner;
|
||||||
|
let arbitrator;
|
||||||
|
|
||||||
if (!offer) {
|
if (!offer) {
|
||||||
if (!offers) {
|
if (!offers) {
|
||||||
throw new Error('Component needs either offer or offers');
|
throw new Error('Component needs either offer or offers');
|
||||||
}
|
}
|
||||||
user = offers[0].user;
|
user = offers[0].user;
|
||||||
owner = offers[0].owner;
|
owner = offers[0].owner;
|
||||||
|
arbitrator = offers[0].arbitrator;
|
||||||
} else {
|
} else {
|
||||||
user = offer.user;
|
user = offer.user;
|
||||||
owner = offer.owner;
|
owner = offer.owner;
|
||||||
|
arbitrator = offer.arbitrator;
|
||||||
offers = [offer];
|
offers = [offer];
|
||||||
}
|
}
|
||||||
const isOwner = addressCompare(userAddress, owner);
|
const isOwner = addressCompare(userAddress, owner);
|
||||||
|
const isArbitrator = addressCompare(userAddress, arbitrator);
|
||||||
|
|
||||||
return (<Row className="border bg-white rounded p-3 mr-0 ml-0 mb-2" tag={Link} to={`/profile/${owner}`}>
|
return (<Row className="border bg-white rounded p-3 mr-0 ml-0 mb-2" tag={Link} to={`/profile/${owner}`}>
|
||||||
<Col className="p-0">
|
<Col className="p-0">
|
||||||
<Row className="mb-2">
|
<Row className="mb-2">
|
||||||
|
@ -31,7 +37,8 @@ const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
<p className={classnames('seller-name', 'm-0', 'font-weight-bold', {
|
<p className={classnames('seller-name', 'm-0', 'font-weight-bold', {
|
||||||
'text-black': !isOwner,
|
'text-black': !isOwner,
|
||||||
'text-success': isOwner
|
'text-success': isOwner,
|
||||||
|
'text-warning': isArbitrator
|
||||||
})}>{user.username}</p>
|
})}>{user.username}</p>
|
||||||
<p className="text-dark m-0">{user.location}</p>
|
<p className="text-dark m-0">{user.location}</p>
|
||||||
</Col>
|
</Col>
|
||||||
|
@ -49,6 +56,7 @@ const Offer = ({offer, offers, withDetail, prices, userAddress}) => {
|
||||||
</p>
|
</p>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>}
|
</Row>}
|
||||||
|
{isArbitrator && <span className="text-warning text-small">You are an arbitrator for this offer</span>}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>);
|
</Row>);
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,7 +86,7 @@ class OffersList extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let filteredOffers = this.props.offers.filter(x => !addressCompare(x.arbitrator, this.props.address));
|
let filteredOffers = this.props.offers;
|
||||||
|
|
||||||
if (this.state.locationCoords) {
|
if (this.state.locationCoords) {
|
||||||
filteredOffers = filteredOffers.filter((offer) => this.calculateDistance(offer.user.coords) < 0.1);
|
filteredOffers = filteredOffers.filter((offer) => this.calculateDistance(offer.user.coords) < 0.1);
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Profile extends Component {
|
||||||
<Col xs="12" className="mt-2">
|
<Col xs="12" className="mt-2">
|
||||||
<h3>Offers</h3>
|
<h3>Offers</h3>
|
||||||
<div>
|
<div>
|
||||||
{profile.offers.map((offer, index) => <Offer disabled={addressCompare(profile.address, address)}
|
{profile.offers.map((offer, index) => <Offer disabled={addressCompare(profile.address, address) || addressCompare(offer.arbitrator, address)}
|
||||||
key={index}
|
key={index}
|
||||||
offer={offer}
|
offer={offer}
|
||||||
prices={prices}
|
prices={prices}
|
||||||
|
|
Loading…
Reference in New Issue