mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 03:16:24 +00:00
OrderPage.js, MakerPage.js use currencies.json
This commit is contained in:
parent
215af668a2
commit
400fb2b21e
@ -2,5 +2,7 @@
|
||||
"1":"USD",
|
||||
"2":"EUR",
|
||||
"3":"ETH",
|
||||
"4":"ABC"
|
||||
"4":"AUD",
|
||||
"5":"BRL",
|
||||
"6":"CAD"
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class Order(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
# Make relational back to ORDER
|
||||
return (f'Order {self.id}: {self.Types(self.type).label} BTC for {self.amount} {self.Currencies(self.currency).label}')
|
||||
return (f'Order {self.id}: {self.Types(self.type).label} BTC for {self.amount} {self.currency_dict[str(self.currency)]}')
|
||||
|
||||
@receiver(pre_delete, sender=Order)
|
||||
def delelete_HTLCs_at_order_deletion(sender, instance, **kwargs):
|
||||
|
@ -11,8 +11,8 @@ export default class BookPage extends Component {
|
||||
type: 1,
|
||||
currencies_dict: {"1":"USD"}
|
||||
};
|
||||
this.getOrderDetails()
|
||||
this.getCurrencyDict()
|
||||
this.getOrderDetails()
|
||||
this.state.currencyCode = this.getCurrencyCode(this.state.currency)
|
||||
}
|
||||
|
||||
|
@ -178,9 +178,10 @@ export default class MakerPage extends Component {
|
||||
}}
|
||||
onChange={this.handleCurrencyChange}
|
||||
>
|
||||
<MenuItem value={1}>USD</MenuItem>
|
||||
<MenuItem value={2}>EUR</MenuItem>
|
||||
<MenuItem value={3}>ETH</MenuItem>
|
||||
{
|
||||
Object.entries(this.state.currencies_dict)
|
||||
.map( ([key, value]) => <MenuItem value={parseInt(key)}>{value}</MenuItem> )
|
||||
}
|
||||
</Select>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
|
@ -40,8 +40,10 @@ export default class OrderPage extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
isExplicit: false,
|
||||
currencies_dict: {"1":"USD"}
|
||||
};
|
||||
this.orderId = this.props.match.params.orderId;
|
||||
this.getCurrencyDict();
|
||||
this.getOrderDetails();
|
||||
}
|
||||
|
||||
@ -49,6 +51,7 @@ export default class OrderPage extends Component {
|
||||
fetch('/api/order' + '?order_id=' + this.orderId)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.log(data)
|
||||
this.setState({
|
||||
statusCode: data.status,
|
||||
statusText: data.status_message,
|
||||
@ -73,12 +76,6 @@ export default class OrderPage extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
// Gets currency code (3 letters) from numeric (e.g., 1 -> USD)
|
||||
// Improve this function so currencies are read from json
|
||||
getCurrencyCode(val){
|
||||
return (val == 1 ) ? "USD": ((val == 2 ) ? "EUR":"ETH")
|
||||
}
|
||||
|
||||
// Fix to use proper react props
|
||||
handleClickBackButton=()=>{
|
||||
window.history.back();
|
||||
@ -97,6 +94,21 @@ export default class OrderPage extends Component {
|
||||
.then((response) => response.json())
|
||||
.then((data) => (console.log(data) & this.getOrderDetails(data.id)));
|
||||
}
|
||||
getCurrencyDict() {
|
||||
fetch('/api/currencies')
|
||||
.then((response) => response.json())
|
||||
.then((data) =>
|
||||
this.setState({
|
||||
currencies_dict: data
|
||||
}));
|
||||
}
|
||||
// Gets currency code (3 letters) from numeric (e.g., 1 -> USD)
|
||||
// Improve this function so currencies are read from json
|
||||
getCurrencyCode(val){
|
||||
console.log("---------------------------------")
|
||||
console.log(val)
|
||||
return this.state.currencies_dict[val.toString()]
|
||||
}
|
||||
|
||||
render (){
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user