diff --git a/frontend/src/components/MakerPage.js b/frontend/src/components/MakerPage.js index 54305ad3..e7546b17 100644 --- a/frontend/src/components/MakerPage.js +++ b/frontend/src/components/MakerPage.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Checkbox, Slider, Switch, Tooltip, Paper, Button , Grid, Typography, TextField, Select, FormHelperText, MenuItem, FormControl, Radio, FormControlLabel, RadioGroup} from "@mui/material" +import { LinearProgress, Checkbox, Slider, Switch, Tooltip, Paper, Button , Grid, Typography, TextField, Select, FormHelperText, MenuItem, FormControl, Radio, FormControlLabel, RadioGroup} from "@mui/material" import { LocalizationProvider, TimePicker} from '@mui/lab'; import DateFnsUtils from "@date-io/date-fns"; import { Link } from 'react-router-dom' @@ -43,7 +43,8 @@ export default class MakerPage extends Component { minTradeSats = 20000; maxTradeSats = 800000; maxBondlessSats = 50000; - minAmountFraction = 0.2; + maxRangeAmountMultiple = 5; + minRangeAmountMultiple = 1.5; constructor(props) { super(props); @@ -62,10 +63,27 @@ export default class MakerPage extends Component { enableAmountRange: false, minAmount: null, bondSize: 1, + limits: null, + minAmount: null, + maxAmount: null, + loadingLimits: false, } this.getCurrencyDict() } + getLimits() { + this.setState({loadingLimits:true}) + fetch('/api/limits/') + .then((response) => response.json()) + .then((data) => this.setState({ + limits:data, + loadingLimits:false, + minAmount: Number(data[this.state.currency]['max_amount']*0.25), + maxAmount: Number(data[this.state.currency]['max_amount']*0.75), + amount: ""}) + & console.log(this.state.limits)); + } + handleTypeChange=(e)=>{ this.setState({ type: e.target.value, @@ -83,9 +101,38 @@ export default class MakerPage extends Component { }); } - handleMinAmountChange=(e)=>{ + handleRangeAmountChange = (e, activeThumb) => { + var maxAmount = this.getMaxAmount(); + var minAmount = this.getMinAmount(); + var lowerValue = e.target.value[0]; + var upperValue = e.target.value[1]; + var minRange = this.minRangeAmountMultiple; + var maxRange = this.maxRangeAmountMultiple; + + if (lowerValue > maxAmount/minRange){ + lowerValue = maxAmount/minRange + } + if (upperValue < minRange*minAmount){ + upperValue = minRange*minAmount + } + + if (lowerValue > upperValue/minRange) { + if (activeThumb === 0) { + upperValue = minRange*lowerValue + } else { + lowerValue = upperValue/minRange + } + }else if(lowerValue < upperValue/maxRange){ + if (activeThumb === 0) { + upperValue = maxRange*lowerValue + } else { + lowerValue = upperValue/maxRange + } + } + this.setState({ - minAmount: e.target.value, + minAmount: lowerValue, + maxAmount: upperValue, }); } @@ -205,11 +252,13 @@ export default class MakerPage extends Component {