From 91544642ae0a23ef2451b03edae959b03a72d978 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sat, 15 Jan 2022 07:12:26 -0800 Subject: [PATCH] Add currency visual flags --- api/logics.py | 2 +- frontend/src/components/BookPage.js | 6 ++++- frontend/src/components/OrderPage.js | 8 +++---- frontend/src/components/getFlags.js | 33 ++++++++++++++++++++++++++ frontend/static/assets/currencies.json | 4 +++- 5 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 frontend/src/components/getFlags.js diff --git a/api/logics.py b/api/logics.py index 2f0eea25..cee59d8a 100644 --- a/api/logics.py +++ b/api/logics.py @@ -89,7 +89,7 @@ class Logics(): exchange_rate = get_exchange_rate(Order.currency_dict[str(order.currency)]) order_rate = float(order.amount) / (float(order.satoshis) / 100000000) premium = order_rate / exchange_rate - 1 - premium = int(premium*100) # 2 decimals left + premium = int(premium*10000)/100 # 2 decimals left price = order_rate significant_digits = 5 diff --git a/frontend/src/components/BookPage.js b/frontend/src/components/BookPage.js index a6a6ceb5..8de89617 100644 --- a/frontend/src/components/BookPage.js +++ b/frontend/src/components/BookPage.js @@ -2,6 +2,7 @@ import React, { Component } from "react"; import { Paper, Button , CircularProgress, ListItemButton, Typography, Grid, Select, MenuItem, FormControl, FormHelperText, List, ListItem, ListItemText, Avatar, RouterLink, ListItemAvatar} from "@mui/material"; import { Link } from 'react-router-dom' import { DataGrid } from '@mui/x-data-grid'; +import getFlags from './getFlags' export default class BookPage extends Component { constructor(props) { @@ -100,7 +101,10 @@ export default class BookPage extends Component { } }, { field: 'type', headerName: 'Type', width: 60 }, { field: 'amount', headerName: 'Amount', type: 'number', width: 80 }, - { field: 'currency', headerName: 'Currency', width: 100 }, + { field: 'currency', headerName: 'Currency', width: 100, + renderCell: (params) => {return ( +
{params.row.currency + " " + getFlags(params.row.currency)}
+ )} }, { field: 'payment_method', headerName: 'Payment Method', width: 180 }, { field: 'price', headerName: 'Price', type: 'number', width: 140, renderCell: (params) => {return ( diff --git a/frontend/src/components/OrderPage.js b/frontend/src/components/OrderPage.js index 1c44ce45..748be167 100644 --- a/frontend/src/components/OrderPage.js +++ b/frontend/src/components/OrderPage.js @@ -47,7 +47,7 @@ export default class OrderPage extends Component { this.getCurrencyDict(); this.getOrderDetails(); - // Change refresh delay according to Order status + // Refresh delais according to Order status this.statusToDelay = { "0": 3000, //'Waiting for maker bond' "1": 30000, //'Public' @@ -207,9 +207,9 @@ export default class OrderPage extends Component { })); } - // set delay to the one matching the order status. If no order status, set delay to 9999999 - setDelay(val){ - return val ? this.statusToDelay[val.toString()] : 99999999; + // set delay to the one matching the order status. If null order status, delay goes to 9999999. + setDelay = (status)=>{ + return status >= 0 ? this.statusToDelay[status.toString()] : 99999999; } getCurrencyCode(val){ diff --git a/frontend/src/components/getFlags.js b/frontend/src/components/getFlags.js new file mode 100644 index 00000000..bdfc98a0 --- /dev/null +++ b/frontend/src/components/getFlags.js @@ -0,0 +1,33 @@ +export default function getFlags(code){ + if(code == 'AUD') return '🇦🇺'; + if(code == 'ARS') return '🇦🇷'; + if(code == 'BRL') return '🇧🇷'; + if(code == 'CAD') return '🇨🇦'; + if(code == 'CHF') return '🇨🇭'; + if(code == 'CLP') return '🇨🇱'; + if(code == 'CNY') return '🇨🇳'; + if(code == 'EUR') return '🇪🇺'; + if(code == 'HKR') return '🇨🇷'; + if(code == 'CZK') return '🇨🇿'; + if(code == 'DKK') return '🇩🇰'; + if(code == 'GBP') return '🇬🇧'; + if(code == 'HKD') return '🇭🇰'; + if(code == 'HUF') return '🇭🇺'; + if(code == 'INR') return '🇮🇳'; + if(code == 'ISK') return '🇮🇸'; + if(code == 'JPY') return '🇯🇵'; + if(code == 'KRW') return '🇰🇷'; + if(code == 'MXN') return '🇲🇽'; + if(code == 'NOK') return '🇳🇴'; + if(code == 'NZD') return '🇳🇿'; + if(code == 'PLN') return '🇵🇱'; + if(code == 'RON') return '🇷🇴'; + if(code == 'RUB') return '🇷🇺'; + if(code == 'SEK') return '🇸🇪'; + if(code == 'SGD') return '🇸🇬'; + if(code == 'VES') return '🇻🇪'; + if(code == 'TRY') return '🇹🇷'; + if(code == 'USD') return '🇺🇸'; + if(code == 'ZAR') return '🇿🇦'; + return '🏳'; +}; \ No newline at end of file diff --git a/frontend/static/assets/currencies.json b/frontend/static/assets/currencies.json index 84294a4f..3376cc5e 100644 --- a/frontend/static/assets/currencies.json +++ b/frontend/static/assets/currencies.json @@ -27,5 +27,7 @@ "26": "INR", "27": "ISK", "28": "PLN", - "29": "RON" + "29": "RON", + "30": "ARS", + "31": "VES" } \ No newline at end of file