From 5ff6e1e78de742b8338b74c8b4834f791625e5ab Mon Sep 17 00:00:00 2001 From: Fernando Porazzi Date: Tue, 17 May 2022 22:27:12 +0200 Subject: [PATCH] Migrate ExchangeSummaryDialog to Dialogs folder This commit migrates the ExchangeSummaryDialog component to the dialogs folder whilst converting it to Typescript --- frontend/src/components/BottomBar.js | 127 ++----------- .../Dialogs/ExchangeSummaryDialog.tsx | 169 ++++++++++++++++++ frontend/src/components/Dialogs/index.ts | 1 + 3 files changed, 188 insertions(+), 109 deletions(-) create mode 100644 frontend/src/components/Dialogs/ExchangeSummaryDialog.tsx diff --git a/frontend/src/components/BottomBar.js b/frontend/src/components/BottomBar.js index d715e327..80c33e97 100644 --- a/frontend/src/components/BottomBar.js +++ b/frontend/src/components/BottomBar.js @@ -28,7 +28,7 @@ import EmojiEventsIcon from '@mui/icons-material/EmojiEvents'; import FavoriteIcon from '@mui/icons-material/Favorite'; import { AmbossIcon , BitcoinSignIcon} from "./Icons"; -import { CommunityDialog } from './Dialogs'; +import { CommunityDialog, ExchangeSummaryDialog } from './Dialogs'; import { getCookie } from "../utils/cookies"; import { pn } from "../utils/prettyNumbers"; @@ -73,7 +73,7 @@ class BottomBar extends Component { this.setState(null) fetch('/api/info/') .then((response) => response.json()) - .then((data) => this.setState(data) + .then((data) => this.setState(data) & this.setState({active_order_id: data.active_order_id ? data.active_order_id : null, last_order_id: data.last_order_id ? data.last_order_id : null}) & this.props.setAppState({nickname:data.nickname, loading:false})); @@ -419,14 +419,13 @@ bottomBarDesktop =()=>{ {this.StatsDialog()} {this.dialogProfile()} - {this.exchangeSummaryDialog()}
- @@ -576,108 +575,6 @@ bottomBarDesktop =()=>{ this.setState({openExchangeSummary: false}); }; - exchangeSummaryDialog =() =>{ - const { t } = this.props; - return( - - - {t("Exchange Summary")} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {(this.state.maker_fee*100).toFixed(3)}% - - - - - {(this.state.taker_fee*100).toFixed(3)}% - - - - - - - - - ) - } - bottomBarPhone =()=>{ const { t } = this.props; var hasRewards = this.state.earned_rewards > 0 ? true: false; @@ -685,13 +582,12 @@ bottomBarPhone =()=>{ return( {this.StatsDialog()} - {this.exchangeSummaryDialog()} {this.dialogProfile()}
- @@ -787,6 +683,19 @@ bottomBarPhone =()=>{ isOpen={this.state.openCommuniy} handleClickCloseCommunity={this.handleClickCloseCommunity} /> + + + {this.bottomBarDesktop()} diff --git a/frontend/src/components/Dialogs/ExchangeSummaryDialog.tsx b/frontend/src/components/Dialogs/ExchangeSummaryDialog.tsx new file mode 100644 index 00000000..3b759ec9 --- /dev/null +++ b/frontend/src/components/Dialogs/ExchangeSummaryDialog.tsx @@ -0,0 +1,169 @@ +import React from "react"; +import { useTranslation } from "react-i18next"; + +import { + Dialog, + DialogContent, + Divider, + Grid, + List, + ListItemText, + ListItem, + ListItemIcon, + Typography, +} from "@mui/material"; + +import InventoryIcon from '@mui/icons-material/Inventory'; +import SellIcon from '@mui/icons-material/Sell'; +import SmartToyIcon from '@mui/icons-material/SmartToy'; +import PercentIcon from '@mui/icons-material/Percent'; +import PriceChangeIcon from '@mui/icons-material/PriceChange'; +import BookIcon from '@mui/icons-material/Book'; + +import { pn } from "../../utils/prettyNumbers"; + +type Props = { + isOpen: boolean; + handleClickCloseExchangeSummary: () => void; + numPublicBuyOrders: number; + numPublicSellOrders: number; + bookLiquidity: number; + activeRobotsToday: number; + lastDayNonkycBtcPremium: number; + makerFee: number; + takerFee: number; +} + +const ExchangeSummaryDialog = ({ + isOpen, + handleClickCloseExchangeSummary, + numPublicBuyOrders, + numPublicSellOrders, + bookLiquidity, + activeRobotsToday, + lastDayNonkycBtcPremium, + makerFee, + takerFee, +}: Props): JSX.Element => { + const { t } = useTranslation(); + + return ( + + + {t("Exchange Summary")} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {(makerFee * 100).toFixed(3)}% + + + + + + {(takerFee * 100).toFixed(3)}% + + + + + + + + ); +}; + +export default ExchangeSummaryDialog; diff --git a/frontend/src/components/Dialogs/index.ts b/frontend/src/components/Dialogs/index.ts index 518f5c9e..96597467 100644 --- a/frontend/src/components/Dialogs/index.ts +++ b/frontend/src/components/Dialogs/index.ts @@ -3,4 +3,5 @@ export { default as InfoDialog } from "./Info"; export { default as LearnDialog } from "./Learn"; export { default as NoRobotDialog } from "./NoRobot"; export { default as StoreTokenDialog } from "./StoreToken"; +export { default as ExchangeSummaryDialog } from "./ExchangeSummaryDialog";