code reviews for using constants and change text

This commit is contained in:
Jonathan Rainville 2019-05-27 10:31:33 -04:00
parent 9340be82d1
commit ab680c22a7
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
6 changed files with 17 additions and 13 deletions

View File

@ -1,5 +1,7 @@
import {ARBITRATION_UNSOLVED} from "../arbitration/constants";
export const tradeStates = {
released: 'released',
released: 'released',
funded: 'funded',
paid: 'paid',
arbitration_open: 'arbitration_open',
@ -23,7 +25,7 @@ export function getTradeStatus(trade) {
case escrowStatus.FUNDED: return tradeStates.funded;
case escrowStatus.PAID: {
if(trade.arbitration && trade.arbitration.open){
if(trade.arbitration.result !== "0"){
if(trade.arbitration.result !== ARBITRATION_UNSOLVED){
return tradeStates.arbitration_closed;
}
return tradeStates.arbitration_open;

View File

@ -152,7 +152,7 @@ class Arbitration extends Component {
<div className="escrow">
<h2>Dispute Details <span className={"arbitrationStatus " + status}>{status}</span></h2>
{escrow.arbitration.result.toString() !== "0" && <Fragment>
{escrow.arbitration.result.toString() !== ARBITRATION_UNSOLVED && <Fragment>
<h3>Dispute resolved</h3>
<p><span className="font-weight-bold">Winner:</span> {escrow.arbitration.result.toString() === ARBITRATION_SOLVED_BUYER ? 'Buyer' : 'Seller'}</p>
</Fragment>}

View File

@ -19,7 +19,7 @@ import four from "../../../../images/escrow/04.png";
import Dispute from "./Dispute";
import ResolvedDispute from "./ResolvedDispute";
import {ARBITRATION_SOLVED_BUYER} from "../../../features/arbitration/constants";
import {ARBITRATION_SOLVED_BUYER, ARBITRATION_UNSOLVED} from "../../../features/arbitration/constants";
const Done = ({trade, rateTransaction, rateStatus}) => (
<Fragment>
@ -132,8 +132,8 @@ class CardEscrowBuyer extends Component {
if (arbitrationDetails && arbitrationDetails.open && arbitrationDetails.result.toString() === "0") {
component = <Dispute/>;
}
if (arbitrationDetails && arbitrationDetails.result.toString() !== "0") {
component = <ResolvedDispute winner={arbitrationDetails.result.toString() === ARBITRATION_SOLVED_BUYER}/>;
if (arbitrationDetails && arbitrationDetails.result.toString() !== ARBITRATION_UNSOLVED) {
component = <ResolvedDispute winner={arbitrationDetails.result.toString() === ARBITRATION_SOLVED_BUYER} isBuyer={true}/>;
}
}

View File

@ -17,7 +17,7 @@ import two from "../../../../images/escrow/02.png";
import four from "../../../../images/escrow/04.png";
import Loading from "../../../components/Loading";
import ResolvedDispute from "./ResolvedDispute";
import {ARBITRATION_SOLVED_SELLER} from "../../../features/arbitration/constants";
import {ARBITRATION_SOLVED_SELLER, ARBITRATION_UNSOLVED} from "../../../features/arbitration/constants";
import Dispute from "./Dispute";
@ -173,7 +173,7 @@ class CardEscrowSeller extends Component {
if (releaseStatus === States.pending || (trade.mining && (trade.status === escrow.helpers.tradeStates.funded || trade.status === escrow.helpers.tradeStates.paid))) step = 5;
if (releaseStatus === States.success || trade.status === escrow.helpers.tradeStates.released) step = 6;
if (arbitrationDetails && arbitrationDetails.open && arbitrationDetails.result.toString() === "0") step = 10;
if (arbitrationDetails && arbitrationDetails.result.toString() !== "0") step = 11;
if (arbitrationDetails && arbitrationDetails.result.toString() !== ARBITRATION_UNSOLVED) step = 11;
let component;
switch (step) {
@ -181,7 +181,7 @@ class CardEscrowSeller extends Component {
component = <Dispute/>;
break;
case 11:
component = <ResolvedDispute winner={arbitrationDetails.result.toString() === ARBITRATION_SOLVED_SELLER}/>;
component = <ResolvedDispute winner={arbitrationDetails.result.toString() === ARBITRATION_SOLVED_SELLER} isBuyer={false}/>;
break;
case 6:
component = <Done/>;

View File

@ -3,16 +3,17 @@ import PropTypes from 'prop-types';
import {faTimes, faCheck} from "@fortawesome/free-solid-svg-icons";
import RoundedIcon from "../../../ui/RoundedIcon";
const ResolvedDispute = ({winner}) => (
const ResolvedDispute = ({winner, isBuyer}) => (
<Fragment>
<RoundedIcon icon={winner ? faCheck : faTimes} bgColor={winner ? 'green' : 'red'}/>
<h2 className="mt-4">Dispute Resolved</h2>
<p className="m-0">The dispute was resolved and you are the {winner ? 'winner' : 'loser'}</p>
<p className="m-0">The dispute was resolved {winner ? 'in your favor' : `in favor of the ${isBuyer ? 'seller' : 'buyer'}`}</p>
</Fragment>
);
ResolvedDispute.propTypes = {
winner: PropTypes.bool
winner: PropTypes.bool,
isBuyer: PropTypes.bool
};
export default ResolvedDispute;

View File

@ -9,6 +9,7 @@ import {withRouter} from "react-router-dom";
import {connect} from "react-redux";
import arbitration from '../../features/arbitration';
import successImage from '../../../images/success.png';
import {ARBITRATION_UNSOLVED} from "../../features/arbitration/constants";
class OpenDispute extends Component {
state = {
@ -23,7 +24,7 @@ class OpenDispute extends Component {
componentDidUpdate() {
if (this.props.escrow.arbitration) {
if(this.props.escrow.arbitration.open || this.props.escrow.arbitration.result !== "0"){
if(this.props.escrow.arbitration.open || this.props.escrow.arbitration.result !== ARBITRATION_UNSOLVED){
this.props.history.push('/');
}
}