From bf35961efb840d3d78b044707c306fef48189662 Mon Sep 17 00:00:00 2001 From: Fernando Porazzi Date: Thu, 19 May 2022 14:33:41 +0200 Subject: [PATCH] Migrate StatsDialog to Dialogs folder Migrate StatsDialog component into its own file and convert its contents to Typescript. --- frontend/src/components/BottomBar.js | 134 ++---------- .../src/components/Dialogs/StatsDialog.tsx | 196 ++++++++++++++++++ frontend/src/components/Dialogs/index.ts | 1 + 3 files changed, 213 insertions(+), 118 deletions(-) create mode 100644 frontend/src/components/Dialogs/StatsDialog.tsx diff --git a/frontend/src/components/BottomBar.js b/frontend/src/components/BottomBar.js index 4a6f0bd5..af410532 100644 --- a/frontend/src/components/BottomBar.js +++ b/frontend/src/components/BottomBar.js @@ -1,8 +1,7 @@ import React, { Component } from 'react' import { withTranslation } from "react-i18next"; -import {FormControlLabel, Link, Switch, CircularProgress, Badge, Tooltip, TextField, ListItemAvatar, Button, Avatar,Paper, Grid, IconButton, Typography, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon, ListItemButton, Divider, Dialog, DialogContent} from "@mui/material"; +import { Badge, Tooltip, ListItemAvatar, Avatar,Paper, Grid, IconButton, Select, MenuItem, ListItemText, ListItem, ListItemIcon, ListItemButton } from "@mui/material"; import MediaQuery from 'react-responsive' -import { Link as LinkRouter } from 'react-router-dom' // Icons import SettingsIcon from '@mui/icons-material/Settings'; @@ -12,29 +11,15 @@ 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 BoltIcon from '@mui/icons-material/Bolt'; -import GitHubIcon from '@mui/icons-material/GitHub'; -import EqualizerIcon from '@mui/icons-material/Equalizer'; - -import PublicIcon from '@mui/icons-material/Public'; -import NumbersIcon from '@mui/icons-material/Numbers'; -import PasswordIcon from '@mui/icons-material/Password'; -import ContentCopy from "@mui/icons-material/ContentCopy"; -import DnsIcon from '@mui/icons-material/Dns'; -import WebIcon from '@mui/icons-material/Web'; -import PersonAddAltIcon from '@mui/icons-material/PersonAddAlt'; -import EmojiEventsIcon from '@mui/icons-material/EmojiEvents'; -import FavoriteIcon from '@mui/icons-material/Favorite'; -import { AmbossIcon , BitcoinSignIcon} from "./Icons"; import { CommunityDialog, ExchangeSummaryDialog, ProfileDialog, + StatsDialog, } from './Dialogs'; import { getCookie } from "../utils/cookies"; -import { pn } from "../utils/prettyNumbers"; class BottomBar extends Component { constructor(props) { @@ -90,105 +75,6 @@ class BottomBar extends Component { this.setState({openStatsForNerds: false}); }; - StatsDialog =() =>{ - const { t } = this.props; - return( - - - {t("Stats For Nerds")} - - - - - - - - - {this.state.network == 'testnet'? - - - - {this.state.node_id.slice(0, 12)+"... (1ML)"} - - - - : - - - - {this.state.node_id.slice(0, 12)+"... (AMBOSS)"} - - - - } - - - - - - {this.state.alternative_site.slice(0, 12)+"...onion"} - - - - - - - - - {this.state.robosats_running_commit_hash.slice(0, 12)+"..."} - - - - - - - - -
- {pn(this.state.last_day_volume)} - -
-
-
- - - - - -
- {pn(this.state.lifetime_volume)} - -
-
-
- - - - - - {t("Made with")+" "} - - {" "+t("and")+" "} - - } - secondary={t("... somewhere on Earth!")}/> - -
- -
-
- ) - } - handleClickOpenCommunity = () => { this.setState({openCommuniy: true}); }; @@ -240,7 +126,6 @@ bottomBarDesktop =()=>{ return( - {this.StatsDialog()} @@ -403,7 +288,6 @@ bottomBarPhone =()=>{ var hasOrder = this.state.active_order_id > 0 & !this.state.profileShown & this.props.avatarLoaded ? true : false; return( - {this.StatsDialog()} @@ -533,6 +417,20 @@ bottomBarPhone =()=>{ setAppState={this.props.setAppState} /> + + {this.bottomBarDesktop()} diff --git a/frontend/src/components/Dialogs/StatsDialog.tsx b/frontend/src/components/Dialogs/StatsDialog.tsx new file mode 100644 index 00000000..9f77ddf9 --- /dev/null +++ b/frontend/src/components/Dialogs/StatsDialog.tsx @@ -0,0 +1,196 @@ +import React from "react"; +import { useTranslation } from "react-i18next"; + +import { + Dialog, + DialogContent, + Divider, + Link, + List, + ListItemText, + ListItem, + ListItemIcon, + Typography, +} from "@mui/material"; + +import BoltIcon from "@mui/icons-material/Bolt"; +import PublicIcon from "@mui/icons-material/Public"; +import DnsIcon from "@mui/icons-material/Dns"; +import WebIcon from "@mui/icons-material/Web"; +import FavoriteIcon from "@mui/icons-material/Favorite"; +import GitHubIcon from "@mui/icons-material/GitHub"; +import EqualizerIcon from "@mui/icons-material/Equalizer"; + +import { AmbossIcon, BitcoinSignIcon } from "../Icons"; + +import { pn } from "../../utils/prettyNumbers"; + +type Props = { + isOpen: boolean; + handleClickCloseStatsForNerds: () => void; + lndVersion: string; + network: string; + nodeAlias: string; + nodeId: string; + alternativeName: string; + alternativeSite: string; + robosatsRunningCommitHash: string; + lastDayVolume: number; + lifetimeVolume: number; +} + +const StatsDialog = ({ + isOpen, + handleClickCloseStatsForNerds, + lndVersion, + network, + nodeAlias, + nodeId, + alternativeName, + alternativeSite, + robosatsRunningCommitHash, + lastDayVolume, + lifetimeVolume, +}: Props): JSX.Element => { + const { t } = useTranslation(); + + return ( + + + {t("Stats For Nerds")} + + + + + + + + + + + + + + {network === "testnet" ? ( + + + + + + + {`${nodeId.slice(0, 12)}... (1ML)`} + + + + ) : ( + + + + + + + {`${nodeId.slice(0, 12)}... (AMBOSS)`} + + + + )} + + + + + + + + + + {`${alternativeSite.slice(0, 12)}...onion`} + + + + + + + + + + + + + {`${robosatsRunningCommitHash.slice(0, 12)}...`} + + + + + + + + + + + +
+ {pn(lastDayVolume)} + +
+
+
+ + + + + + + + +
+ {pn(lifetimeVolume)} + +
+
+
+ + + + + + + + {`${t("Made with")} `} + + {` ${t("and")} `} + + + } + secondary={t("... somewhere on Earth!")} + /> + +
+
+
+ ); +}; + +export default StatsDialog; diff --git a/frontend/src/components/Dialogs/index.ts b/frontend/src/components/Dialogs/index.ts index 3d6b0bdc..4c020d48 100644 --- a/frontend/src/components/Dialogs/index.ts +++ b/frontend/src/components/Dialogs/index.ts @@ -5,4 +5,5 @@ export { default as NoRobotDialog } from "./NoRobot"; export { default as StoreTokenDialog } from "./StoreToken"; export { default as ExchangeSummaryDialog } from "./ExchangeSummaryDialog"; export { default as ProfileDialog } from "./ProfileDialog"; +export { default as StatsDialog } from "./StatsDialog";