mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
Fix chat reloading after confirming fiat sent
This commit is contained in:
@ -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() {
|
getOrderDetails() {
|
||||||
this.setState(null)
|
this.setState(null)
|
||||||
fetch('/api/order' + '?order_id=' + this.orderId)
|
fetch('/api/order' + '?order_id=' + this.orderId)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {console.log(data) &
|
.then((data) => this.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
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are used to refresh the 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)
|
fetch('/api/order/' + '?order_id=' + this.orderId, requestOptions)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => (this.setState({badRequest:data.bad_request})
|
.then((data) => this.setStateCool(data));
|
||||||
& console.log(data)
|
|
||||||
& this.getOrderDetails(data.id)));
|
|
||||||
}
|
}
|
||||||
getCurrencyDict() {
|
getCurrencyDict() {
|
||||||
fetch('/static/assets/currencies.json')
|
fetch('/static/assets/currencies.json')
|
||||||
|
|||||||
@ -256,7 +256,7 @@ export default class TradeBox extends Component {
|
|||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<SmartToyIcon/>
|
<SmartToyIcon/>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary={'000 coming soon'} secondary="Robots looking at the book"/>
|
<ListItemText primary={'coming soon'} secondary="Robots looking at the book"/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
<Divider/>
|
<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(
|
return(
|
||||||
<Grid container spacing={1}>
|
<Grid container spacing={1}>
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
@ -548,11 +572,10 @@ handleRatingChange=(e)=>{
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Chat orderId={this.props.data.id} urNick={this.props.data.urNick}/>
|
<Chat orderId={this.props.data.id} urNick={this.props.data.urNick}/>
|
||||||
|
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
{openDisputeButton ? this.showOpenDisputeButton() : ""}
|
{showDisputeButton ? this.showOpenDisputeButton() : ""}
|
||||||
{sendFiatButton ? this.showFiatSentButton() : ""}
|
{showSendButton ? this.showFiatSentButton() : ""}
|
||||||
{receivedFiatButton ? this.showFiatReceivedButton() : ""}
|
{showReveiceButton ? this.showFiatReceivedButton() : ""}
|
||||||
</Grid>
|
</Grid>
|
||||||
{this.showBondIsLocked()}
|
{this.showBondIsLocked()}
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -605,13 +628,8 @@ handleRatingChange=(e)=>{
|
|||||||
{this.props.data.isBuyer & this.props.data.statusCode == 7 ? this.showWaitingForEscrow() : ""}
|
{this.props.data.isBuyer & this.props.data.statusCode == 7 ? this.showWaitingForEscrow() : ""}
|
||||||
{this.props.data.isSeller & this.props.data.statusCode == 8 ? this.showWaitingForBuyerInvoice() : ""}
|
{this.props.data.isSeller & this.props.data.statusCode == 8 ? this.showWaitingForBuyerInvoice() : ""}
|
||||||
|
|
||||||
{/* In Chatroom - No fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton) */}
|
{/* In Chatroom */}
|
||||||
{this.props.data.isBuyer & this.props.data.statusCode == 9 ? this.showChat(true,false,true) : ""}
|
{this.props.data.statusCode == 9 || this.props.data.statusCode == 10 ? this.showChat(): ""}
|
||||||
{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) : ""}
|
|
||||||
|
|
||||||
{/* Trade Finished */}
|
{/* Trade Finished */}
|
||||||
{(this.props.data.isSeller & this.props.data.statusCode > 12 & this.props.data.statusCode < 15) ? this.showRateSelect() : ""}
|
{(this.props.data.isSeller & this.props.data.statusCode > 12 & this.props.data.statusCode < 15) ? this.showRateSelect() : ""}
|
||||||
|
|||||||
Reference in New Issue
Block a user