diff --git a/frontend/src/components/OrderPage.js b/frontend/src/components/OrderPage.js
index b415a07b..6e5ebd0c 100644
--- a/frontend/src/components/OrderPage.js
+++ b/frontend/src/components/OrderPage.js
@@ -73,52 +73,55 @@ export default class OrderPage extends Component {
}
}
+ // Unneeded for the most part. Let's keep variable names as they come from the API
+ // Will need some renaming everywhere, but will decrease the mess.
+ setStateCool=(data)=>{
+ this.setState({
+ loading: false,
+ delay: this.setDelay(data.status),
+ id: data.id,
+ statusCode: data.status,
+ statusText: data.status_message,
+ type: data.type,
+ currency: data.currency,
+ currencyCode: this.getCurrencyCode(data.currency),
+ amount: data.amount,
+ paymentMethod: data.payment_method,
+ isExplicit: data.is_explicit,
+ premium: data.premium,
+ satoshis: data.satoshis,
+ makerId: data.maker,
+ isParticipant: data.is_participant,
+ urNick: data.ur_nick,
+ makerNick: data.maker_nick,
+ takerId: data.taker,
+ takerNick: data.taker_nick,
+ isMaker: data.is_maker,
+ isTaker: data.is_taker,
+ isBuyer: data.is_buyer,
+ isSeller: data.is_seller,
+ penalty: data.penalty,
+ expiresAt: data.expires_at,
+ badRequest: data.bad_request,
+ bondInvoice: data.bond_invoice,
+ bondSatoshis: data.bond_satoshis,
+ escrowInvoice: data.escrow_invoice,
+ escrowSatoshis: data.escrow_satoshis,
+ invoiceAmount: data.invoice_amount,
+ total_secs_expiry: data.total_secs_exp,
+ numSimilarOrders: data.num_similar_orders,
+ priceNow: data.price_now,
+ premiumNow: data.premium_now,
+ robotsInBook: data.robots_in_book,
+ premiumPercentile: data.premium_percentile,
+ numSimilarOrders: data.num_similar_orders
+ })
+ }
getOrderDetails() {
this.setState(null)
fetch('/api/order' + '?order_id=' + this.orderId)
.then((response) => response.json())
- .then((data) => {console.log(data) &
- this.setState({
- loading: false,
- delay: this.setDelay(data.status),
- id: data.id,
- statusCode: data.status,
- statusText: data.status_message,
- type: data.type,
- currency: data.currency,
- currencyCode: this.getCurrencyCode(data.currency),
- amount: data.amount,
- paymentMethod: data.payment_method,
- isExplicit: data.is_explicit,
- premium: data.premium,
- satoshis: data.satoshis,
- makerId: data.maker,
- isParticipant: data.is_participant,
- urNick: data.ur_nick,
- makerNick: data.maker_nick,
- takerId: data.taker,
- takerNick: data.taker_nick,
- isMaker: data.is_maker,
- isTaker: data.is_taker,
- isBuyer: data.is_buyer,
- isSeller: data.is_seller,
- penalty: data.penalty,
- expiresAt: data.expires_at,
- badRequest: data.bad_request,
- bondInvoice: data.bond_invoice,
- bondSatoshis: data.bond_satoshis,
- escrowInvoice: data.escrow_invoice,
- escrowSatoshis: data.escrow_satoshis,
- invoiceAmount: data.invoice_amount,
- total_secs_expiry: data.total_secs_exp,
- numSimilarOrders: data.num_similar_orders,
- priceNow: data.price_now,
- premiumNow: data.premium_now,
- robotsInBook: data.robots_in_book,
- premiumPercentile: data.premium_percentile,
- numSimilarOrders: data.num_similar_orders
- })
- });
+ .then((data) => this.setStateCool(data));
}
// These are used to refresh the data
@@ -197,9 +200,7 @@ export default class OrderPage extends Component {
};
fetch('/api/order/' + '?order_id=' + this.orderId, requestOptions)
.then((response) => response.json())
- .then((data) => (this.setState({badRequest:data.bad_request})
- & console.log(data)
- & this.getOrderDetails(data.id)));
+ .then((data) => this.setStateCool(data));
}
getCurrencyDict() {
fetch('/static/assets/currencies.json')
diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js
index b4c865dd..7b91e9cc 100644
--- a/frontend/src/components/TradeBox.js
+++ b/frontend/src/components/TradeBox.js
@@ -256,7 +256,7 @@ export default class TradeBox extends Component {
-
+
@@ -526,7 +526,31 @@ handleRatingChange=(e)=>{
)
}
- showChat(sendFiatButton, receivedFiatButton, openDisputeButton){
+ showChat=()=>{
+ //In Chatroom - No fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
+ if(this.props.data.isBuyer & this.props.data.statusCode == 9){
+ var showSendButton=true;
+ var showReveiceButton=false;
+ var showDisputeButton=true;
+ }
+ if(this.props.data.isSeller & this.props.data.statusCode == 9){
+ var showSendButton=false;
+ var showReveiceButton=false;
+ var showDisputeButton=true;
+ }
+
+ //In Chatroom - Fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
+ if(this.props.data.isBuyer & this.props.data.statusCode == 10){
+ var showSendButton=false;
+ var showReveiceButton=false;
+ var showDisputeButton=true;
+ }
+ if(this.props.data.isSeller & this.props.data.statusCode == 10){
+ var showSendButton=false;
+ var showReveiceButton=true;
+ var showDisputeButton=true;
+ }
+
return(
@@ -548,11 +572,10 @@ handleRatingChange=(e)=>{
-
- {openDisputeButton ? this.showOpenDisputeButton() : ""}
- {sendFiatButton ? this.showFiatSentButton() : ""}
- {receivedFiatButton ? this.showFiatReceivedButton() : ""}
+ {showDisputeButton ? this.showOpenDisputeButton() : ""}
+ {showSendButton ? this.showFiatSentButton() : ""}
+ {showReveiceButton ? this.showFiatReceivedButton() : ""}
{this.showBondIsLocked()}
@@ -605,13 +628,8 @@ handleRatingChange=(e)=>{
{this.props.data.isBuyer & this.props.data.statusCode == 7 ? this.showWaitingForEscrow() : ""}
{this.props.data.isSeller & this.props.data.statusCode == 8 ? this.showWaitingForBuyerInvoice() : ""}
- {/* In Chatroom - No fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton) */}
- {this.props.data.isBuyer & this.props.data.statusCode == 9 ? this.showChat(true,false,true) : ""}
- {this.props.data.isSeller & this.props.data.statusCode == 9 ? this.showChat(false,false,true) : ""}
-
- {/* In Chatroom - Fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton) */}
- {this.props.data.isBuyer & this.props.data.statusCode == 10 ? this.showChat(false,false,true) : ""}
- {this.props.data.isSeller & this.props.data.statusCode == 10 ? this.showChat(false,true,true) : ""}
+ {/* In Chatroom */}
+ {this.props.data.statusCode == 9 || this.props.data.statusCode == 10 ? this.showChat(): ""}
{/* Trade Finished */}
{(this.props.data.isSeller & this.props.data.statusCode > 12 & this.props.data.statusCode < 15) ? this.showRateSelect() : ""}