mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 19:36: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",
|
"1":"USD",
|
||||||
"2":"EUR",
|
"2":"EUR",
|
||||||
"3":"ETH",
|
"3":"ETH",
|
||||||
"4":"ABC"
|
"4":"AUD",
|
||||||
|
"5":"BRL",
|
||||||
|
"6":"CAD"
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ class Order(models.Model):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# Make relational back to ORDER
|
# 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)
|
@receiver(pre_delete, sender=Order)
|
||||||
def delelete_HTLCs_at_order_deletion(sender, instance, **kwargs):
|
def delelete_HTLCs_at_order_deletion(sender, instance, **kwargs):
|
||||||
|
@ -11,8 +11,8 @@ export default class BookPage extends Component {
|
|||||||
type: 1,
|
type: 1,
|
||||||
currencies_dict: {"1":"USD"}
|
currencies_dict: {"1":"USD"}
|
||||||
};
|
};
|
||||||
this.getOrderDetails()
|
|
||||||
this.getCurrencyDict()
|
this.getCurrencyDict()
|
||||||
|
this.getOrderDetails()
|
||||||
this.state.currencyCode = this.getCurrencyCode(this.state.currency)
|
this.state.currencyCode = this.getCurrencyCode(this.state.currency)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,9 +178,10 @@ export default class MakerPage extends Component {
|
|||||||
}}
|
}}
|
||||||
onChange={this.handleCurrencyChange}
|
onChange={this.handleCurrencyChange}
|
||||||
>
|
>
|
||||||
<MenuItem value={1}>USD</MenuItem>
|
{
|
||||||
<MenuItem value={2}>EUR</MenuItem>
|
Object.entries(this.state.currencies_dict)
|
||||||
<MenuItem value={3}>ETH</MenuItem>
|
.map( ([key, value]) => <MenuItem value={parseInt(key)}>{value}</MenuItem> )
|
||||||
|
}
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -40,8 +40,10 @@ export default class OrderPage extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isExplicit: false,
|
isExplicit: false,
|
||||||
|
currencies_dict: {"1":"USD"}
|
||||||
};
|
};
|
||||||
this.orderId = this.props.match.params.orderId;
|
this.orderId = this.props.match.params.orderId;
|
||||||
|
this.getCurrencyDict();
|
||||||
this.getOrderDetails();
|
this.getOrderDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +51,7 @@ export default class OrderPage extends Component {
|
|||||||
fetch('/api/order' + '?order_id=' + this.orderId)
|
fetch('/api/order' + '?order_id=' + this.orderId)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
console.log(data)
|
||||||
this.setState({
|
this.setState({
|
||||||
statusCode: data.status,
|
statusCode: data.status,
|
||||||
statusText: data.status_message,
|
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
|
// Fix to use proper react props
|
||||||
handleClickBackButton=()=>{
|
handleClickBackButton=()=>{
|
||||||
window.history.back();
|
window.history.back();
|
||||||
@ -97,6 +94,21 @@ export default class OrderPage extends Component {
|
|||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => (console.log(data) & this.getOrderDetails(data.id)));
|
.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 (){
|
render (){
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user