From 638d3b1d6cce0a8a0e1b2a1f208d94f81c0aa1e0 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 17 Jul 2022 11:11:10 -0700 Subject: [PATCH 1/2] Fix serve summary when order partially finished. Trade summary as accordion --- api/logics.py | 2 +- frontend/src/components/TradeBox.js | 9 +- frontend/src/components/TradeSummary.tsx | 286 ++++++++++++----------- 3 files changed, 159 insertions(+), 138 deletions(-) diff --git a/api/logics.py b/api/logics.py index a9101dfc..2805807d 100644 --- a/api/logics.py +++ b/api/logics.py @@ -1574,7 +1574,7 @@ class Logics: Summarizes a finished order. Returns a dict with amounts, fees, costs, etc, for buyer and seller. ''' - if order.status != Order.Status.SUC: + if not order.status in [Order.Status.EXP, Order.Status.SUC, Order.Status.PAY, Order.Status.FAI]: return False, {'bad_summary':'Order has not finished yet'} context = {} diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js index a5637a89..87fbe965 100644 --- a/frontend/src/components/TradeBox.js +++ b/frontend/src/components/TradeBox.js @@ -24,6 +24,8 @@ import BoltIcon from '@mui/icons-material/Bolt'; import LinkIcon from '@mui/icons-material/Link'; import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet'; import FavoriteIcon from '@mui/icons-material/Favorite'; +import RocketLaunchIcon from '@mui/icons-material/RocketLaunch'; +import RefreshIcon from '@mui/icons-material/Refresh'; import { NewTabIcon } from "./Icons"; import { getCookie } from "../utils/cookies"; @@ -1275,9 +1277,9 @@ handleRatingRobosatsChange=(e)=>{ : null} - + - + {show_renew ? @@ -1285,7 +1287,7 @@ handleRatingRobosatsChange=(e)=>{ {this.state.renewLoading ? : - + } : null} @@ -1299,6 +1301,7 @@ handleRatingRobosatsChange=(e)=>{ makerSummary={this.props.data.maker_summary} takerSummary={this.props.data.taker_summary} platformSummary={this.props.data.platform_summary} + orderId={this.props.data.orderId} /> diff --git a/frontend/src/components/TradeSummary.tsx b/frontend/src/components/TradeSummary.tsx index 91d125a1..69565977 100644 --- a/frontend/src/components/TradeSummary.tsx +++ b/frontend/src/components/TradeSummary.tsx @@ -6,19 +6,24 @@ import { ToggleButton, ToggleButtonGroup, List, - Chip, ListItem, ListItemText, ListItemIcon, Grid, - Divider, + Tooltip, + IconButton, + Accordion, + AccordionSummary, + AccordionDetails, Typography, } from "@mui/material" import { pn } from "../utils/prettyNumbers"; +import { saveAsJson } from "../utils/saveFile"; // Icons import FlagWithProps from "./FlagWithProps"; -import PercentIcon from '@mui/icons-material/Percent'; +import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; +import DownloadIcon from '@mui/icons-material/Download'; import AccountBalanceIcon from '@mui/icons-material/AccountBalance'; import RouteIcon from '@mui/icons-material/Route'; import AccountBoxIcon from '@mui/icons-material/AccountBox'; @@ -39,7 +44,7 @@ type Props = { makerSummary: Record; takerSummary: Record; platformSummary: Record; - bondPercent: number; + orderId: number; } const TradeSummary = ({ @@ -50,145 +55,158 @@ const TradeSummary = ({ makerSummary, takerSummary, platformSummary, - bondPercent, + orderId, }: Props): JSX.Element => { const { t } = useTranslation(); const [buttonValue, setButtonValue] = useState(isMaker ? 0 : 2); var userSummary = buttonValue == 0 ? makerSummary : takerSummary; - + return ( - - - - - - - setButtonValue(0)}> - -   - {t("Maker")} - - setButtonValue(1)}> - - - setButtonValue(2)}> - {t("Taker")} -   - - - - - {/* Maker/Taker Summary */} -
- - - - - {userSummary.is_buyer ? - - : - } -
}> - - - - + + }> + {t("Trade Summary")} + + +
+ + setButtonValue(0)}> + +   + {t("Maker")} + + setButtonValue(1)}> + + + setButtonValue(2)}> + {t("Taker")} +   + + + + + + saveAsJson(`order${orderId}-summary.json`, {'order_id':orderId,'currency':currencyCode,'maker':makerSummary,'taker':takerSummary,'platform':platformSummary})} + > + + + + +
+ {/* Maker/Taker Summary */} +
+ + + + + {userSummary.is_buyer ? + + : + } +
}> + + + + - -
- -
-
- - - - - - - - + +
+ +
+
+ +
+ + + + + + - - - - {userSummary.is_swap ? - - - - - - - - : null} + + + + {userSummary.is_swap ? + + + + + + + + : null} - - - - - - {t("Unlocked")}}/> - - - - {/* Platform Summary */} -
- - - - - - - - - - - - - - -
+ + + + + + {t("Unlocked")}}/> + + + + {/* Platform Summary */} +
+ + + + + + + + + + + + + + +
+
+
); }; From 2eb72654cf59fa2dcd411eb6bcce2a06890c1027 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 17 Jul 2022 13:42:29 -0700 Subject: [PATCH 2/2] Load languages.json from http backend --- frontend/src/components/App.js | 4 +- frontend/src/components/BottomBar.js | 6 +- frontend/src/components/i18n.js | 130 ++++++++++++++---- .../{src => static}/locales/CONTRIBUTING.MD | 0 frontend/{src => static}/locales/ca.json | 0 frontend/{src => static}/locales/de.json | 0 frontend/{src => static}/locales/en.json | 0 frontend/{src => static}/locales/es.json | 0 frontend/{src => static}/locales/eu.json | 0 frontend/{src => static}/locales/fr.json | 0 frontend/{src => static}/locales/it.json | 0 frontend/{src => static}/locales/pl.json | 0 frontend/{src => static}/locales/pt.json | 0 frontend/{src => static}/locales/ru.json | 0 frontend/{src => static}/locales/zh.json | 0 15 files changed, 113 insertions(+), 27 deletions(-) rename frontend/{src => static}/locales/CONTRIBUTING.MD (100%) rename frontend/{src => static}/locales/ca.json (100%) rename frontend/{src => static}/locales/de.json (100%) rename frontend/{src => static}/locales/en.json (100%) rename frontend/{src => static}/locales/es.json (100%) rename frontend/{src => static}/locales/eu.json (100%) rename frontend/{src => static}/locales/fr.json (100%) rename frontend/{src => static}/locales/it.json (100%) rename frontend/{src => static}/locales/pl.json (100%) rename frontend/{src => static}/locales/pt.json (100%) rename frontend/{src => static}/locales/ru.json (100%) rename frontend/{src => static}/locales/zh.json (100%) diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index 2e2c654b..c82b25b9 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -1,4 +1,4 @@ -import React, { Component } from "react"; +import React, { Component , Suspense } from "react"; import ReactDOM from 'react-dom/client'; import HomePage from "./HomePage"; import { CssBaseline, IconButton , Link} from "@mui/material"; @@ -36,6 +36,7 @@ export default class App extends Component { render() { return ( + @@ -48,6 +49,7 @@ export default class App extends Component { + ); } } diff --git a/frontend/src/components/BottomBar.js b/frontend/src/components/BottomBar.js index de7df16c..2876ccb6 100644 --- a/frontend/src/components/BottomBar.js +++ b/frontend/src/components/BottomBar.js @@ -294,15 +294,17 @@ bottomBarDesktop =()=>{ } LangSelect = () => { - const { i18n} = this.props; + const { i18n } = this.props; + const lang = i18n.resolvedLanguage == null ? 'en' : i18n.resolvedLanguage.substring(0,2); const flagProps = { width: 20, height: 20, }; + return(