import React, { Component } from "react"; import { Paper, FormControl , Grid, Typography, FormHelperText, TextField, List, ListItem, ListItemText, Divider} from "@material-ui/core" import QRCode from "react-qr-code"; export default class TradeBox extends Component { constructor(props) { super(props); this.state = { delay: 100, // checks for new state in OrderPage ever 100 ms }; this.data = this.props.data } // These are used to refresh the data componentDidMount() { this.interval = setInterval(this.tick, this.state.delay); } componentDidUpdate(prevProps, prevState) { if (prevState.delay !== this.state.delay) { clearInterval(this.interval); this.interval = setInterval(this.tick, this.state.delay); } } componentWillUnmount() { clearInterval(this.interval); } handleDelayChange = (e) => { this.setState({ delay: Number(e.target.value) }); } tick = () => { this.data = this.props.data; } showQRInvoice=()=>{ return ( Robots around here usually show commitment {this.data.isMaker ? Lock {this.data.bondSatoshis} Sats to PUBLISH order : Lock {this.data.bondSatoshis} Sats to TAKE the order } ); } showEscrowQRInvoice=()=>{ return ( Deposit {this.data.escrowSatoshis} Sats as trade collateral ); } showTakerFound=()=>{ // Make some sound here! The maker might have been waiting for long return ( A taker has been found! Please wait for the taker to confirm his commitment by locking a bond. ); } showMakerWait=()=>{ return ( Your order is public, wait for a taker.

Be patient while robots check the book. It might take some time. This box will ring 🔊 once a robot takes your order.

Please note that if your premium is too high, or if your currency or payment methods are not popular, your order might expire untaken. Your bond will return to you (no action needed).

{/* TODO API sends data for a more confortable wait */}
) } // showInputInvoice(){ // } // showWaitingForEscrow(){ // } // showWaitingForBuyerInvoice({ // }) // showFiatSentButton(){ // } // showFiatReceivedButton(){ // } // showOpenDisputeButton(){ // } // showRateSelect(){ // } render() { return ( TradeBox {/* Maker and taker Bond request */} {this.data.bondInvoice ? this.showQRInvoice() : ""} {/* Waiting for taker and taker bond request */} {this.data.isMaker & this.data.statusCode == 1 ? this.showMakerWait() : ""} {this.data.isMaker & this.data.statusCode == 3 ? this.showTakerFound() : ""} {/* Send Invoice (buyer) and deposit collateral (seller) */} {this.data.isSeller & this.data.escrowInvoice != null ? this.showEscrowQRInvoice() : ""} {this.data.isBuyer & this.data.invoiceAmount != null ? this.showInputInvoice() : ""} {this.data.isBuyer & this.data.statusCode == 7 ? this.showWaitingForEscrow() : ""} {this.data.isSeller & this.data.statusCode == 8 ? this.showWaitingForBuyerInvoice() : ""} {/* In Chatroom */} {this.data.isBuyer & this.data.statusCode == 9 ? this.showChat() & this.showFiatSentButton() : ""} {this.data.isSeller & this.data.statusCode ==9 ? this.showChat() : ""} {this.data.isBuyer & this.data.statusCode == 10 ? this.showChat() & this.showOpenDisputeButton() : ""} {this.data.isSeller & this.data.statusCode == 10 ? this.showChat() & this.showFiatReceivedButton() & this.showOpenDisputeButton(): ""} {/* Trade Finished */} {this.data.isSeller & this.data.statusCode > 12 & this.data.statusCode < 15 ? this.showRateSelect() : ""} {/* TODO */} {/* */} {/* */} ); } }