diff --git a/frontend/src/components/MakerPage.js b/frontend/src/components/MakerPage.js index b4fa4320..b98490b9 100644 --- a/frontend/src/components/MakerPage.js +++ b/frontend/src/components/MakerPage.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Paper, Button , Grid, Typography, TextField, Select, FormHelperText, MenuItem, FormControl, Radio, FormControlLabel, RadioGroup} from "@mui/material" +import { Paper, Button , Grid, Typography, TextField, Select, FormHelperText, MenuItem, FormControl, Radio, FormControlLabel, RadioGroup, dividerClasses} from "@mui/material" import { Link } from 'react-router-dom' import getFlags from './getFlags' @@ -22,6 +22,9 @@ const csrftoken = getCookie('csrftoken'); // pretty numbers function pn(x) { + if(x==null){ + return(null) + } return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } @@ -66,25 +69,36 @@ export default class MakerPage extends Component { } handlePaymentMethodChange=(e)=>{ this.setState({ - payment_method: e.target.value, + payment_method: e.target.value, + badPaymentMethod: e.target.value.length > 35, }); } handlePremiumChange=(e)=>{ + if(e.target.value > 999){ + var bad_premium = "Must be less than 999%" + } + if(e.target.value < -100){ + var bad_premium = "Must be more than -100%" + } + this.setState({ - premium: e.target.value, + premium: e.target.value, + badPremium: bad_premium, }); } + handleSatoshisChange=(e)=>{ - var bad_sats = e.target.value > this.maxTradeSats ? - ("Must be less than "+pn(this.maxTradeSats)): - (e.target.value < this.minTradeSats ? - ("Must be more than "+pn(this.minTradeSats)): null) + if(e.target.value > this.maxTradeSats){ + var bad_sats = "Must be less than " + pn(this.maxTradeSats) + } + if(e.target.value < this.minTradeSats){ + var bad_sats = "Must be more than "+pn(this.minTradeSats) + } this.setState({ satoshis: e.target.value, badSatoshis: bad_sats, - }) - ; + }); } handleClickRelative=(e)=>{ this.setState({ @@ -112,8 +126,8 @@ export default class MakerPage extends Component { amount: this.state.amount, payment_method: this.state.payment_method, is_explicit: this.state.is_explicit, - premium: this.state.premium, - satoshis: this.state.satoshis, + premium: this.state.is_explicit ? null: this.state.premium, + satoshis: this.state.is_explicit ? this.state.satoshis: null, }), }; fetch("/api/make/",requestOptions) @@ -136,16 +150,17 @@ export default class MakerPage extends Component { return this.state.currencies_dict[val.toString()] } + render() { return ( - + Order Maker - + @@ -167,10 +182,11 @@ export default class MakerPage extends Component { - + +
- + />
+
+ +

-
- @@ -285,8 +316,8 @@ export default class MakerPage extends Component { : ""}
- Create a BTC {this.state.type==0 ? "buy":"sell"} order for {this.state.amount} {this.state.currencyCode} - {this.state.is_explicit ? " of " + this.state.satoshis + " Satoshis" : + Create a BTC {this.state.type==0 ? "buy":"sell"} order for {pn(this.state.amount)} {this.state.currencyCode} + {this.state.is_explicit ? " of " + pn(this.state.satoshis) + " Satoshis" : (this.state.premium == 0 ? " at market price" : (this.state.premium > 0 ? " at a " + this.state.premium + "% premium":" at a " + -this.state.premium + "% discount") ) diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js index e4583f4c..12e8ff4d 100644 --- a/frontend/src/components/TradeBox.js +++ b/frontend/src/components/TradeBox.js @@ -677,7 +677,7 @@ handleRatingChange=(e)=>{ - + )