Fix chat reloading after confirming fiat sent

This commit is contained in:
Reckless_Satoshi 2022-01-19 14:44:31 -08:00
parent 7c0e3a74fa
commit 300a385589
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 77 additions and 58 deletions

View File

@ -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')

View File

@ -256,7 +256,7 @@ export default class TradeBox extends Component {
<ListItemIcon>
<SmartToyIcon/>
</ListItemIcon>
<ListItemText primary={'000 coming soon'} secondary="Robots looking at the book"/>
<ListItemText primary={'coming soon'} secondary="Robots looking at the book"/>
</ListItem>
<Divider/>
@ -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(
<Grid container spacing={1}>
<Grid item xs={12} align="center">
@ -548,11 +572,10 @@ handleRatingChange=(e)=>{
</Grid>
<Chat orderId={this.props.data.id} urNick={this.props.data.urNick}/>
<Grid item xs={12} align="center">
{openDisputeButton ? this.showOpenDisputeButton() : ""}
{sendFiatButton ? this.showFiatSentButton() : ""}
{receivedFiatButton ? this.showFiatReceivedButton() : ""}
{showDisputeButton ? this.showOpenDisputeButton() : ""}
{showSendButton ? this.showFiatSentButton() : ""}
{showReveiceButton ? this.showFiatReceivedButton() : ""}
</Grid>
{this.showBondIsLocked()}
</Grid>
@ -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() : ""}