robosats/frontend/src/components/BottomBar.js

830 lines
37 KiB
JavaScript
Raw Normal View History

2022-01-14 16:21:42 +00:00
import React, { Component } from 'react'
import { withTranslation, Trans} 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";
2022-01-28 14:30:45 +00:00
import MediaQuery from 'react-responsive'
import { Link as LinkRouter } from 'react-router-dom'
import Flags from 'country-flag-icons/react/3x2'
2022-01-14 16:21:42 +00:00
// Icons
import SettingsIcon from '@mui/icons-material/Settings';
2022-01-15 10:21:36 +00:00
import PeopleIcon from '@mui/icons-material/People';
2022-01-14 16:21:42 +00:00
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';
2022-01-14 17:35:27 +00:00
import PriceChangeIcon from '@mui/icons-material/PriceChange';
2022-01-15 00:28:19 +00:00
import BoltIcon from '@mui/icons-material/Bolt';
import GitHubIcon from '@mui/icons-material/GitHub';
import EqualizerIcon from '@mui/icons-material/Equalizer';
2022-01-15 10:21:36 +00:00
import SendIcon from '@mui/icons-material/Send';
2022-01-15 15:45:44 +00:00
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 BookIcon from '@mui/icons-material/Book';
2022-03-05 11:48:11 +00:00
import PersonAddAltIcon from '@mui/icons-material/PersonAddAlt';
import EmojiEventsIcon from '@mui/icons-material/EmojiEvents';
import AmbossIcon from "./icons/AmbossIcon";
import FavoriteIcon from '@mui/icons-material/Favorite';
2022-01-14 16:21:42 +00:00
import { getCookie } from "../utils/cookies";
// pretty numbers
function pn(x) {
if(x == null){
return 'null'
}else{
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
}
class BottomBar extends Component {
2022-01-14 16:21:42 +00:00
constructor(props) {
super(props);
this.state = {
2022-01-15 00:28:19 +00:00
openStatsForNerds: false,
2022-01-15 10:21:36 +00:00
openCommuniy: false,
2022-01-28 14:30:45 +00:00
openExchangeSummary:false,
2022-03-06 11:45:06 +00:00
openClaimRewards: false,
2022-01-18 17:52:48 +00:00
num_public_buy_orders: 0,
num_public_sell_orders: 0,
book_liquidity: 0,
2022-01-18 17:52:48 +00:00
active_robots_today: 0,
maker_fee: 0,
taker_fee: 0,
2022-03-13 12:00:21 +00:00
last_day_nonkyc_btc_premium: 0,
last_day_volume: 0,
lifetime_volume: 0,
2022-01-27 22:51:57 +00:00
robosats_running_commit_hash: '000000000000000',
openProfile: false,
profileShown: false,
alternative_site: 'robosats...',
node_id: '00000000',
showRewards: false,
referral_code: '',
earned_rewards: 0,
2022-03-06 11:45:06 +00:00
rewardInvoice: null,
badInvoice: false,
showRewardsSpinner: false,
withdrawn: false,
2022-01-14 16:21:42 +00:00
};
this.getInfo();
}
2022-01-14 16:21:42 +00:00
getInfo() {
this.setState(null)
fetch('/api/info/')
.then((response) => response.json())
.then((data) => this.setState(data) & this.setState({active_order_id: data.active_order_id ? data.active_order_id : null})
& this.props.setAppState({nickname:data.nickname, loading:false}));
2022-01-14 16:21:42 +00:00
}
2022-01-15 00:28:19 +00:00
handleClickOpenStatsForNerds = () => {
2022-01-15 10:21:36 +00:00
this.setState({openStatsForNerds: true});
2022-01-15 00:28:19 +00:00
};
2022-01-27 22:51:57 +00:00
2022-01-15 00:28:19 +00:00
handleClickCloseStatsForNerds = () => {
2022-01-15 10:21:36 +00:00
this.setState({openStatsForNerds: false});
2022-01-15 00:28:19 +00:00
};
StatsDialog =() =>{
const { t } = this.props;
2022-01-15 00:28:19 +00:00
return(
<Dialog
open={this.state.openStatsForNerds}
onClose={this.handleClickCloseStatsForNerds}
aria-labelledby="stats-for-nerds-dialog-title"
aria-describedby="stats-for-nerds-description"
>
<DialogContent>
<Typography component="h5" variant="h5">{t("Stats For Nerds")}</Typography>
<List dense>
2022-01-15 00:28:19 +00:00
<Divider/>
<ListItem>
<ListItemIcon><BoltIcon/></ListItemIcon>
<ListItemText primary={this.state.lnd_version} secondary={t("LND version")}/>
2022-01-15 00:28:19 +00:00
</ListItem>
2022-01-15 15:45:44 +00:00
<Divider/>
{this.state.network == 'testnet'?
<ListItem>
<ListItemIcon><DnsIcon/></ListItemIcon>
<ListItemText secondary={this.state.node_alias}>
<Link target="_blank" href={"https://1ml.com/testnet/node/"
+ this.state.node_id}>{this.state.node_id.slice(0, 12)+"... (1ML)"}
</Link>
</ListItemText>
2022-03-14 17:57:06 +00:00
</ListItem>
:
<ListItem>
<ListItemIcon><AmbossIcon/></ListItemIcon>
<ListItemText secondary={this.state.node_alias}>
<Link target="_blank" href={"https://amboss.space/node/"
2022-03-14 17:57:06 +00:00
+ this.state.node_id}>{this.state.node_id.slice(0, 12)+"... (AMBOSS)"}
</Link>
</ListItemText>
</ListItem>
2022-03-14 17:57:06 +00:00
}
<Divider/>
<ListItem>
<ListItemIcon><WebIcon/></ListItemIcon>
<ListItemText secondary={this.state.alternative_name}>
<Link target="_blank" href={"http://"+this.state.alternative_site}>{this.state.alternative_site.slice(0, 12)+"...onion"}
</Link>
</ListItemText>
</ListItem>
2022-01-15 00:28:19 +00:00
<Divider/>
<ListItem>
<ListItemIcon><GitHubIcon/></ListItemIcon>
<ListItemText secondary={t("Currently running commit hash")}>
<Link target="_blank" href={"https://github.com/Reckless-Satoshi/robosats/tree/"
2022-01-27 22:51:57 +00:00
+ this.state.robosats_running_commit_hash}>{this.state.robosats_running_commit_hash.slice(0, 12)+"..."}
</Link>
2022-01-15 00:28:19 +00:00
</ListItemText>
</ListItem>
2022-01-15 15:45:44 +00:00
2022-01-15 00:28:19 +00:00
<Divider/>
<ListItem>
<ListItemIcon><EqualizerIcon/></ListItemIcon>
<ListItemText primary={pn(this.state.last_day_volume)+" Sats"} secondary={t("24h contracted volume")}/>
2022-01-15 00:28:19 +00:00
</ListItem>
2022-01-15 15:45:44 +00:00
<Divider/>
<ListItem>
<ListItemIcon><EqualizerIcon/></ListItemIcon>
<ListItemText primary={pn(this.state.lifetime_volume)+" BTC"} secondary={t("Lifetime contracted volume")}/>
</ListItem>
2022-01-15 15:45:44 +00:00
<Divider/>
<ListItem>
<ListItemIcon><PublicIcon/></ListItemIcon>
<ListItemText primary={
<div style={{display:'flex', alignItems:'center', justifyContent:'left', flexWrap:'wrap'}}>
<span>{t("Made with")+" "}</span>
<FavoriteIcon sx={{ color: "#FF0000", height: '22px',width: '22px'}}/>
<span>{" "+t("and")+" "}</span>
<BoltIcon sx={{ color: "#fcba03", height: '23px',width: '23px'}}/>
</div>}
secondary={t("... somewhere on Earth!")}/>
2022-01-15 15:45:44 +00:00
</ListItem>
2022-01-15 00:28:19 +00:00
</List>
2022-01-15 15:45:44 +00:00
2022-01-15 00:28:19 +00:00
</DialogContent>
</Dialog>
)
}
2022-01-15 10:21:36 +00:00
handleClickOpenCommunity = () => {
this.setState({openCommuniy: true});
};
handleClickCloseCommunity = () => {
this.setState({openCommuniy: false});
};
CommunityDialog =() =>{
const { t } = this.props;
2022-01-28 14:30:45 +00:00
2022-01-15 10:21:36 +00:00
return(
<Dialog
open={this.state.openCommuniy}
onClose={this.handleClickCloseCommunity}
aria-labelledby="community-dialog-title"
aria-describedby="community-description"
>
<DialogContent>
<Typography component="h5" variant="h5">{t("Community")}</Typography>
2022-01-15 10:21:36 +00:00
<Typography component="body2" variant="body2">
<p>{t("Support is only offered via public channels. Join our Telegram community if you have questions or want to hang out with other cool robots. Please, use our Github Issues if you find a bug or want to see new features!")}</p>
2022-01-15 10:21:36 +00:00
</Typography>
<List>
2022-01-15 10:21:36 +00:00
<Divider/>
<ListItemButton component="a" target="_blank" href="https://t.me/robosats">
2022-01-15 10:21:36 +00:00
<ListItemIcon><SendIcon/></ListItemIcon>
<ListItemText primary={t("Join the RoboSats group")}
secondary={t("Telegram (English / Main)")}/>
2022-01-15 10:21:36 +00:00
</ListItemButton>
<Divider/>
<ListItem>
2022-01-15 10:21:36 +00:00
<ListItemIcon><SendIcon/></ListItemIcon>
<ListItemText secondary={t("RoboSats Telegram Communities")}>
<Tooltip title={t("Join RoboSats Spanish speaking community!")}>
<IconButton component="a" target="_blank" href="https://t.me/robosats_es"><Flags.ES width={30} height={30} style={{filter: 'drop-shadow(2px 2px 2px #444444)'}}/></IconButton>
</Tooltip>
<Tooltip title={t("Join RoboSats Russian speaking community!")}>
<IconButton component="a" target="_blank" href="https://t.me/robosats_ru"><Flags.RU width={30} height={30} style={{filter: 'drop-shadow(2px 2px 2px #444444)'}}/></IconButton>
</Tooltip>
<Tooltip title={t("Join RoboSats Chinese speaking community!")}>
<IconButton component="a" target="_blank" href="https://t.me/robosats_cn"><Flags.CN width={30} height={30} style={{filter: 'drop-shadow(2px 2px 2px #444444)'}}/></IconButton>
</Tooltip>
<Tooltip title={t("Join RoboSats English speaking community!")}>
<IconButton component="a" target="_blank" href="https://t.me/robosats"><Flags.US width={30} height={30} style={{filter: 'drop-shadow(2px 2px 2px #444444)'}}/></IconButton>
</Tooltip>
</ListItemText>
</ListItem>
2022-01-15 10:21:36 +00:00
<Divider/>
<ListItemButton component="a" target="_blank" href="https://github.com/Reckless-Satoshi/robosats/issues">
2022-01-15 10:21:36 +00:00
<ListItemIcon><GitHubIcon/></ListItemIcon>
<ListItemText primary={t("Tell us about a new feature or a bug")}
secondary={t("Github Issues - The Robotic Satoshis Open Source Project")}/>
2022-01-15 10:21:36 +00:00
</ListItemButton>
</List>
</DialogContent>
</Dialog>
)
}
handleClickOpenProfile = () => {
this.getInfo();
this.setState({openProfile: true, profileShown: true});
};
handleClickCloseProfile = () => {
this.setState({openProfile: false});
};
handleSubmitInvoiceClicked=()=>{
this.setState({
badInvoice:false,
showRewardsSpinner: true,
});
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
body: JSON.stringify({
'invoice': this.state.rewardInvoice,
}),
};
fetch('/api/reward/', requestOptions)
.then((response) => response.json())
.then((data) => console.log(data) & this.setState({
badInvoice:data.bad_invoice,
openClaimRewards: data.successful_withdrawal ? false : true,
earned_rewards: data.successful_withdrawal ? 0 : this.state.earned_rewards,
withdrawn: data.successful_withdrawal ? true : false,
showRewardsSpinner: false,
}));
2022-03-06 11:45:06 +00:00
}
getHost(){
var url = (window.location != window.parent.location) ? this.getHost(document.referrer) : document.location.href;
return url.split('/')[2]
}
dialogProfile =() =>{
const { t } = this.props;
return(
<Dialog
open={this.state.openProfile}
onClose={this.handleClickCloseProfile}
aria-labelledby="profile-title"
aria-describedby="profile-description"
>
<DialogContent>
<Typography component="h5" variant="h5">{t("Your Profile")}</Typography>
<List>
<Divider/>
<ListItem className="profileNickname">
<ListItemText secondary={t("Your robot")}>
<Typography component="h6" variant="h6">
{this.props.nickname ?
<div style={{position:'relative',left:'-7px'}}>
<div style={{display:'flex', alignItems:'center', justifyContent:'left', flexWrap:'wrap', width:300}}>
<BoltIcon sx={{ color: "#fcba03", height: '28px',width: '24px'}}/><a>{this.props.nickname}</a><BoltIcon sx={{ color: "#fcba03", height: '28px',width: '24px'}}/>
</div>
</div>
: ""}
</Typography>
</ListItemText>
<ListItemAvatar>
<Avatar className='profileAvatar'
sx={{ width: 65, height:65 }}
2022-02-01 19:43:33 +00:00
alt={this.props.nickname}
src={this.props.nickname ? window.location.origin +'/static/assets/avatars/' + this.props.nickname + '.png' : null}
/>
</ListItemAvatar>
</ListItem>
2022-03-05 11:48:11 +00:00
<Divider/>
{this.state.active_order_id ?
<ListItemButton onClick={this.handleClickCloseProfile} to={'/order/'+this.state.active_order_id} component={LinkRouter}>
<ListItemIcon>
<Badge badgeContent="" color="primary">
<NumbersIcon color="primary"/>
</Badge>
</ListItemIcon>
<ListItemText primary={t("One active order #{{orderID}}",{orderID: this.state.active_order_id})} secondary={t("Your current order")}/>
</ListItemButton>
:
<ListItem>
<ListItemIcon><NumbersIcon/></ListItemIcon>
<ListItemText primary={t("No active orders")} secondary={t("Your current order")}/>
</ListItem>
}
<ListItem>
<ListItemIcon>
<PasswordIcon/>
</ListItemIcon>
<ListItemText secondary={t("Your token (will not remain here)")}>
{this.props.token ?
<TextField
disabled
label={t("Back it up!")}
value={this.props.token }
variant='filled'
size='small'
InputProps={{
endAdornment:
<Tooltip disableHoverListener enterTouchDelay="0" title={t("Copied!")}>
2022-03-05 11:48:11 +00:00
<IconButton onClick= {()=>navigator.clipboard.writeText(this.props.token)}>
<ContentCopy />
</IconButton>
</Tooltip>,
}}
/>
:
t("Cannot remember")}
2022-03-05 11:48:11 +00:00
</ListItemText>
</ListItem>
<Divider/>
<Grid spacing={1} align="center">
<FormControlLabel labelPlacement="start"control={
<Switch
checked={this.state.showRewards}
onChange={()=> this.setState({showRewards: !this.state.showRewards})}/>}
label={t("Rewards and compensations")}
2022-03-05 11:48:11 +00:00
/>
</Grid>
<div style={{ display: this.state.showRewards ? '':'none'}}>
<ListItem>
<ListItemIcon>
<PersonAddAltIcon/>
</ListItemIcon>
<ListItemText secondary={t("Share to earn 100 Sats per trade")}>
<TextField
label={t("Your referral link")}
value={this.getHost()+'/ref/'+this.state.referral_code}
size='small'
InputProps={{
endAdornment:
<Tooltip disableHoverListener enterTouchDelay="0" title={t("Copied!")}>
<IconButton onClick= {()=>navigator.clipboard.writeText('http://'+this.getHost()+'/ref/'+this.state.referral_code)}>
<ContentCopy />
</IconButton>
</Tooltip>,
2022-03-06 11:45:06 +00:00
}}
/>
</ListItemText>
</ListItem>
<ListItem>
<ListItemIcon>
<EmojiEventsIcon/>
</ListItemIcon>
{!this.state.openClaimRewards ?
<ListItemText secondary={t("Your earned rewards")}>
<Grid container xs={12}>
<Grid item xs={9}>
<Typography>{this.state.earned_rewards+" Sats"}</Typography>
</Grid>
<Grid item xs={3}>
<Button disabled={this.state.earned_rewards==0? true : false} onClick={() => this.setState({openClaimRewards:true})} variant="contained" size="small">{t("Claim")}</Button>
</Grid>
2022-03-06 11:45:06 +00:00
</Grid>
</ListItemText>
:
<form style={{maxWidth: 270}}>
<Grid alignItems="stretch" style={{ display: "flex"}} align="center">
<Grid item alignItems="stretch" style={{ display: "flex" }} align="center">
<TextField
error={this.state.badInvoice}
helperText={this.state.badInvoice ? this.state.badInvoice : "" }
label={t("Invoice for {{amountSats}} Sats", {amountSats: this.state.earned_rewards})}
size="small"
value={this.state.rewardInvoice}
onChange={e => {
this.setState({ rewardInvoice: e.target.value });
}}
/>
</Grid>
<Grid item alignItems="stretch" style={{ display: "flex" }}>
<Button sx={{maxHeight:38}} onClick={this.handleSubmitInvoiceClicked} variant="contained" color="primary" size="small">{t("Submit")}</Button>
</Grid>
2022-03-06 11:45:06 +00:00
</Grid>
</form>
}
</ListItem>
{this.state.showRewardsSpinner?
<div style={{display: 'flex', justifyContent: 'center'}}>
<CircularProgress/>
</div>
:""}
{this.state.withdrawn?
<div style={{display: 'flex', justifyContent: 'center'}}>
<Typography color="primary" variant="body2"><b>{t("There it goes, thank you!🥇")}</b></Typography>
</div>
:""}
</div>
</List>
</DialogContent>
</Dialog>
)
}
2022-01-15 10:21:36 +00:00
2022-01-28 14:30:45 +00:00
bottomBarDesktop =()=>{
const { t } = this.props;
2022-01-28 14:30:45 +00:00
return(
<Paper elevation={6} style={{height:40}}>
2022-01-15 00:28:19 +00:00
<this.StatsDialog/>
2022-01-15 10:21:36 +00:00
<this.CommunityDialog/>
<this.dialogProfile/>
<this.exchangeSummaryDialog/>
2022-01-14 16:21:42 +00:00
<Grid container xs={12}>
2022-01-14 17:35:27 +00:00
<Grid item xs={1.9}>
<div style={{display: this.props.avatarLoaded ? '':'none'}}>
<ListItemButton onClick={this.handleClickOpenProfile} >
<Tooltip open={this.state.earned_rewards > 0 ? true: false} title={t("You can claim satoshis!")}>
<Tooltip open={(this.state.active_order_id > 0 & !this.state.profileShown & this.props.avatarLoaded) ? true: false}
title={t("You have an active order")}>
<ListItemAvatar sx={{ width: 30, height: 30 }} >
<Badge badgeContent={(this.state.active_order_id > 0 & !this.state.profileShown) ? "": null} color="primary">
<Avatar className='flippedSmallAvatar' sx={{margin: 0, top: -13}}
alt={this.props.nickname}
imgProps={{
onLoad:() => this.props.setAppState({avatarLoaded: true}),
}}
src={this.props.nickname ? window.location.origin +'/static/assets/avatars/' + this.props.nickname + '.png' : null}
/>
</Badge>
</ListItemAvatar>
</Tooltip>
2022-03-10 21:35:16 +00:00
</Tooltip>
<ListItemText primary={this.props.nickname}/>
</ListItemButton>
</div>
2022-01-14 16:21:42 +00:00
</Grid>
2022-01-14 17:35:27 +00:00
<Grid item xs={1.9}>
2022-01-14 16:21:42 +00:00
<ListItem className="bottomItem">
<ListItemIcon size="small">
<IconButton onClick={this.handleClickOpenExchangeSummary}><InventoryIcon/></IconButton>
2022-01-14 16:21:42 +00:00
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.num_public_buy_orders}
secondary={t("Public Buy Orders")} />
2022-01-14 16:21:42 +00:00
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
<Grid item xs={1.9}>
2022-01-14 16:21:42 +00:00
<ListItem className="bottomItem">
<ListItemIcon size="small">
<IconButton onClick={this.handleClickOpenExchangeSummary}><SellIcon/></IconButton>
2022-01-14 16:21:42 +00:00
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.num_public_sell_orders}
secondary={t("Public Sell Orders")} />
2022-01-14 16:21:42 +00:00
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
<Grid item xs={1.9}>
2022-01-14 16:21:42 +00:00
<ListItem className="bottomItem">
<ListItemIcon size="small">
<IconButton onClick={this.handleClickOpenExchangeSummary}><SmartToyIcon/></IconButton>
2022-01-14 16:21:42 +00:00
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.active_robots_today}
secondary={t("Today Active Robots")}/>
2022-01-14 16:21:42 +00:00
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
<Grid item xs={1.9}>
2022-01-14 16:21:42 +00:00
<ListItem className="bottomItem">
<ListItemIcon size="small">
<IconButton onClick={this.handleClickOpenExchangeSummary}><PriceChangeIcon/></IconButton>
2022-01-14 16:21:42 +00:00
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.last_day_nonkyc_btc_premium+"%"}
secondary={t("24h Avg Premium")} />
2022-01-14 16:21:42 +00:00
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
<Grid item xs={1.5}>
2022-01-14 17:35:27 +00:00
<ListItem className="bottomItem">
<ListItemIcon size="small">
< IconButton onClick={this.handleClickOpenExchangeSummary}><PercentIcon/></IconButton>
2022-01-14 17:35:27 +00:00
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={(this.state.maker_fee + this.state.taker_fee)*100}
secondary={t("Trade Fee")} />
2022-01-14 17:35:27 +00:00
</ListItem>
</Grid>
2022-01-14 16:21:42 +00:00
<Grid container item xs={1}>
<Grid item xs={6}>
<this.LangSelect/>
2022-01-14 16:21:42 +00:00
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show community and support links")}>
<IconButton
color="primary"
aria-label="Community"
2022-01-15 10:21:36 +00:00
onClick={this.handleClickOpenCommunity} >
<PeopleIcon />
2022-01-14 16:21:42 +00:00
</IconButton>
</Tooltip>
2022-01-14 16:21:42 +00:00
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show stats for nerds")}>
<IconButton color="primary"
aria-label="Stats for Nerds"
onClick={this.handleClickOpenStatsForNerds} >
<SettingsIcon />
</IconButton>
</Tooltip>
</Grid>
2022-01-14 17:35:27 +00:00
2022-01-14 16:21:42 +00:00
</Grid>
</Grid>
</Paper>
2022-01-28 14:30:45 +00:00
)
}
handleChangeLang=(e)=>{
2022-04-17 19:14:22 +00:00
const { i18n } = this.props;
i18n.changeLanguage(e.target.value)
}
2022-04-17 19:14:22 +00:00
LangSelect = () => {
const { i18n} = this.props;
return(
<Select
size = 'small'
value = {i18n.resolvedLanguage.substring(0,2)}
inputProps={{
style: {textAlign:"center"}
}}
onChange={this.handleChangeLang}>
<MenuItem value={'en'}>EN</MenuItem>
Spanish translation (#96) * Translate tp Spanish (#93) * update_es.json * Update es.json Translate eng to esp from line 222 to end Co-authored-by: mamifiero <99733022+mamifiero@users.noreply.github.com> * Fit book and maker UI for variable length text * Correction and style of the Spanish translation (#95) * Correction and style of the Spanish translation The following terms have been unified and adjusted only in Spanish, but can be done in English base too: * Satoshis, satoshis, sats = Sats (in honour of RoboSats) * Robot (always first capital letter in honour of RoboSats) * Lightning, lightning, LN, Lightning Network = Lightningç * Telegram, TG = Telegram * Trade, Swap = Trade (Intercambio) * Trade counterpart, Peer, Trading peer = Peer (Compañero) * Hold invoice, Bond & Fidelity Bond = Bond (Fianza) * Trade collateral, Collateral, Trade escrow, Escrow = Collateral (Colateral) * Burner contact method, Burner email = Burner contact method (Método de contacto de usar y tirar) * Hidden service (deprecated), Onion services, .onion site = Onion site (sitio cebolla) https://tb-manual.torproject.org/es/onion-services/ * Tor Browser (Navegador Tor) https://tb-manual.torproject.org/es/about/ * Craiglist is not common on spanish countries, so now inserted WallaPop * Update es.json Co-authored-by: decentralized.b <58108487+decentralizedb@users.noreply.github.com> Co-authored-by: mamifiero <99733022+mamifiero@users.noreply.github.com> Co-authored-by: ibertario <68381662+ibertario@users.noreply.github.com>
2022-04-15 16:15:57 +00:00
<MenuItem value={'es'}>ES</MenuItem>
<MenuItem disabled={true} value={'de'}>DE</MenuItem>
<MenuItem disabled={true} value={'ru'}>RU</MenuItem>
<MenuItem disabled={true} value={'zh'}>ZH</MenuItem>
</Select>
)
}
2022-01-28 14:30:45 +00:00
handleClickOpenExchangeSummary = () => {
this.getInfo();
2022-01-28 14:30:45 +00:00
this.setState({openExchangeSummary: true});
};
handleClickCloseExchangeSummary = () => {
this.setState({openExchangeSummary: false});
};
exchangeSummaryDialog =() =>{
const { t } = this.props;
2022-01-28 14:30:45 +00:00
return(
<Dialog
open={this.state.openExchangeSummary}
onClose={this.handleClickCloseExchangeSummary}
aria-labelledby="exchange-summary-title"
aria-describedby="exchange-summary-description"
>
<DialogContent>
<Typography component="h5" variant="h5">{t("Exchange Summary")}</Typography>
2022-01-28 14:30:45 +00:00
<List dense>
<ListItem >
<ListItemIcon size="small">
<InventoryIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.num_public_buy_orders}
secondary={t("Public buy orders")} />
2022-01-28 14:30:45 +00:00
</ListItem>
<Divider/>
<ListItem >
<ListItemIcon size="small">
<SellIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.num_public_sell_orders}
secondary={t("Public sell orders")} />
2022-01-28 14:30:45 +00:00
</ListItem>
<Divider/>
<ListItem >
<ListItemIcon size="small">
<BookIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={pn(this.state.book_liquidity)+" Sats"}
secondary={t("Book liquidity")}/>
</ListItem>
<Divider/>
2022-01-28 14:30:45 +00:00
<ListItem >
<ListItemIcon size="small">
<SmartToyIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.active_robots_today}
secondary={t("Today active robots")} />
2022-01-28 14:30:45 +00:00
</ListItem>
<Divider/>
<ListItem >
<ListItemIcon size="small">
<PriceChangeIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.last_day_nonkyc_btc_premium+"%"}
secondary={t("24h non-KYC bitcoin premium")} />
2022-01-28 14:30:45 +00:00
</ListItem>
<Divider/>
<ListItem >
<ListItemIcon size="small">
<PercentIcon/>
</ListItemIcon>
<Grid container xs={12}>
<Grid item xs={6}>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
secondary={t("Maker fee")}>
{(this.state.maker_fee*100).toFixed(3)}%
</ListItemText>
</Grid>
<Grid item xs={6}>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
secondary={t("Taker fee")}>
{(this.state.taker_fee*100).toFixed(3)}%
</ListItemText>
</Grid>
</Grid>
2022-01-28 14:30:45 +00:00
</ListItem>
</List>
2022-01-28 14:30:45 +00:00
</DialogContent>
</Dialog>
)
}
bottomBarPhone =()=>{
const { t } = this.props;
2022-01-28 14:30:45 +00:00
return(
<Paper elevation={6} style={{height:40}}>
<this.StatsDialog/>
<this.CommunityDialog/>
<this.exchangeSummaryDialog/>
<this.dialogProfile/>
2022-01-28 14:30:45 +00:00
<Grid container xs={12}>
<Grid item xs={1.6}>
2022-02-01 19:43:33 +00:00
<div style={{display: this.props.avatarLoaded ? '':'none'}}>
<Tooltip open={this.state.earned_rewards > 0 ? true: false} title={t("You can claim satoshis!")}>
2022-03-10 21:35:16 +00:00
<Tooltip open={(this.state.active_order_id > 0 & !this.state.profileShown & this.props.avatarLoaded) ? true: false}
title={t("You have an active order")}>
<IconButton onClick={this.handleClickOpenProfile} sx={{margin: 0, bottom: 17, right: 8}} >
<Badge badgeContent={(this.state.active_order_id >0 & !this.state.profileShown) ? "": null} color="primary">
<Avatar className='phoneFlippedSmallAvatar'
sx={{ width: 55, height:55 }}
alt={this.props.nickname}
imgProps={{
onLoad:() => this.props.setAppState({avatarLoaded: true}),
}}
src={this.props.nickname ? window.location.origin +'/static/assets/avatars/' + this.props.nickname + '.png' : null}
/>
</Badge>
</IconButton>
</Tooltip>
2022-03-10 21:35:16 +00:00
</Tooltip>
2022-02-01 19:43:33 +00:00
</div>
2022-01-28 14:30:45 +00:00
</Grid>
<Grid item xs={1.6} align="center">
<Tooltip enterTouchDelay="300" title={t("Number of public BUY orders")}>
<IconButton onClick={this.handleClickOpenExchangeSummary} >
<Badge badgeContent={this.state.num_public_buy_orders} color="action">
<InventoryIcon />
</Badge>
</IconButton>
</Tooltip>
2022-01-28 14:30:45 +00:00
</Grid>
<Grid item xs={1.6} align="center">
<Tooltip enterTouchDelay="300" title={t("Number of public SELL orders")}>
<IconButton onClick={this.handleClickOpenExchangeSummary} >
<Badge badgeContent={this.state.num_public_sell_orders} color="action">
<SellIcon />
</Badge>
</IconButton>
</Tooltip>
2022-01-28 14:30:45 +00:00
</Grid>
<Grid item xs={1.6} align="center">
<Tooltip enterTouchDelay="300" title={t("Today active robots")}>
<IconButton onClick={this.handleClickOpenExchangeSummary} >
<Badge badgeContent={this.state.active_robots_today} color="action">
<SmartToyIcon />
</Badge>
</IconButton>
</Tooltip>
2022-01-28 14:30:45 +00:00
</Grid>
<Grid item xs={1.8} align="center">
<Tooltip enterTouchDelay="300" title={t("24h non-KYC bitcoin premium")}>
<IconButton onClick={this.handleClickOpenExchangeSummary} >
2022-03-13 12:00:21 +00:00
<Badge badgeContent={this.state.last_day_nonkyc_btc_premium+"%"} color="action">
<PriceChangeIcon />
</Badge>
</IconButton>
</Tooltip>
2022-01-28 14:30:45 +00:00
</Grid>
<Grid container item xs={3.8}>
<Grid item xs={6}>
<this.LangSelect/>
2022-01-28 14:30:45 +00:00
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show community and support links")}>
<IconButton
color="primary"
aria-label="Community"
2022-01-28 14:30:45 +00:00
onClick={this.handleClickOpenCommunity} >
<PeopleIcon />
</IconButton>
</Tooltip>
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show stats for nerds")}>
<IconButton color="primary"
aria-label="Stats for Nerds"
onClick={this.handleClickOpenStatsForNerds} >
<SettingsIcon />
</IconButton>
</Tooltip>
2022-01-28 14:30:45 +00:00
</Grid>
</Grid>
</Grid>
</Paper>
)
}
render() {
return (
<div>
<MediaQuery minWidth={1200}>
<this.bottomBarDesktop/>
</MediaQuery>
<MediaQuery maxWidth={1199}>
<this.bottomBarPhone/>
</MediaQuery>
</div>
2022-01-14 16:21:42 +00:00
)
}
}
export default withTranslation()(BottomBar);