Skip to content

Commit

Permalink
Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoporazzi committed May 2, 2022
1 parent 354680b commit 67b68f5
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 142 deletions.
9 changes: 6 additions & 3 deletions frontend/src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import { render } from "react-dom";
import ReactDOM from 'react-dom/client';
import HomePage from "./HomePage";
import { CssBaseline, IconButton} from "@mui/material";
import { ThemeProvider, createTheme } from '@mui/material/styles';
Expand Down Expand Up @@ -46,5 +46,8 @@ export default class App extends Component {
}
}

const appDiv = document.getElementById("app");
render(<App />, appDiv);
const root = ReactDOM.createRoot(
document.getElementById("app")
);

root.render(<App />);
10 changes: 5 additions & 5 deletions frontend/src/components/AutocompletePayments.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const InputWrapper = styled('div')(
display: flex;
flex-wrap: wrap;
overflow-y:auto;
&:hover {
border-color: ${theme.palette.mode === 'dark' ? (error? '#f44336':'#ffffff') : (error? '#dd0000' :'#2f2f2f')};
}
Expand Down Expand Up @@ -233,7 +233,7 @@ export default function AutocompletePayments(props) {
if(a || a == null){props.onAutocompleteChange(optionsToString(value))}
return false
};

return (
<Root>
<div style={{height:'5px'}}></div>
Expand All @@ -252,7 +252,7 @@ export default function AutocompletePayments(props) {
<ListHeader ><i>{props.listHeaderText+" "} </i> </ListHeader>
</div>
{groupedOptions.map((option, index) => (
<li {...getOptionProps({ option, index })}>
<li key={option.name} {...getOptionProps({ option, index })}>
<Button fullWidth={true} color='inherit' size="small" sx={{textTransform: "none"}} style={{justifyContent: "flex-start"}}>
<div style={{position:'relative', right: '4px', top:'4px'}}>
<AddIcon style={{color : '#1976d2'}} sx={{width:18,height:18}} />
Expand All @@ -268,7 +268,7 @@ export default function AutocompletePayments(props) {
:null)
:null}
</Listbox>
) :
) :
//Here goes what happens if there is no groupedOptions
(getInputProps().value.length > 0 ?
<Listbox {...getListboxProps()}>
Expand All @@ -278,4 +278,4 @@ export default function AutocompletePayments(props) {
}
</Root>
);
}
}
68 changes: 34 additions & 34 deletions frontend/src/components/BookPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class BookPage extends Component {
}
}


// Colors for the status badges
statusBadgeColor(status){
if(status=='Active'){return("success")}
Expand All @@ -90,7 +90,7 @@ class BookPage extends Component {
.map((order) =>
({id: order.id,
avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png',
robot: order.maker_nick,
robot: order.maker_nick,
robot_status: order.maker_status,
type: order.type ? t("Seller"): t("Buyer"),
amount: order.amount,
Expand All @@ -106,17 +106,17 @@ class BookPage extends Component {
loading={this.props.loading}
columns={[
// { field: 'id', headerName: 'ID', width: 40 },
{ field: 'robot', headerName: t("Robot"), width: 240,
{ field: 'robot', headerName: t("Robot"), width: 240,
renderCell: (params) => {return (
<ListItemButton style={{ cursor: "pointer" }}>
<ListItemAvatar>
<Tooltip placement="right" enterTouchDelay="0" title={t(params.row.robot_status)}>
<Tooltip placement="right" enterTouchDelay={0} title={t(params.row.robot_status)}>
<Badge variant="dot" overlap="circular" badgeContent="" color={this.statusBadgeColor(params.row.robot_status)}>
<Badge overlap="circular" anchorOrigin={{horizontal: 'right', vertical: 'bottom'}} badgeContent={<div style={{position:"relative", left:"11px", top:"2px"}}> {params.row.type == t("Buyer") ? <SendReceiveIcon sx={{transform: "scaleX(-1)",height:"20px",width:"20px"}} color="secondary"/> : <SendReceiveIcon sx={{height:"20px",width:"20px"}} color="primary"/>}</div>}>
<div style={{ width: 45, height: 45 }}>
<Image className='bookAvatar'
disableError='true'
disableSpinner='true'
<Image className='bookAvatar'
disableError={true}
disableSpinner={true}
color='null'
alt={params.row.robot}
src={params.row.avatar}
Expand All @@ -135,7 +135,7 @@ class BookPage extends Component {
renderCell: (params) => {return (
<div style={{ cursor: "pointer" }}>{this.amountToString(params.row.amount,params.row.has_range, params.row.min_amount, params.row.max_amount)}</div>
)}},
{ field: 'currency', headerName: t("Currency"), width: 100,
{ field: 'currency', headerName: t("Currency"), width: 100,
renderCell: (params) => {return (
<div style={{ cursor: "pointer", display:'flex',alignItems:'center', flexWrap:'wrap'}}>{params.row.currency+" "}{getFlags(params.row.currency)}</div>)
}},
Expand All @@ -152,7 +152,7 @@ class BookPage extends Component {
<div style={{ cursor: "pointer" }}>{parseFloat(parseFloat(params.row.premium).toFixed(4))+"%" }</div>
)} },
]}

components={{
NoRowsOverlay: () => (
<Stack height="100%" alignItems="center" justifyContent="center">
Expand Down Expand Up @@ -187,7 +187,7 @@ class BookPage extends Component {
.map((order) =>
({id: order.id,
avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png',
robot: order.maker_nick,
robot: order.maker_nick,
robot_status: order.maker_status,
type: order.type ? t("Seller"): t("Buyer"),
amount: order.amount,
Expand All @@ -203,14 +203,14 @@ class BookPage extends Component {

columns={[
// { field: 'id', headerName: 'ID', width: 40 },
{ field: 'robot', headerName: t("Robot"), width: 64,
{ field: 'robot', headerName: t("Robot"), width: 64,
renderCell: (params) => {return (
<div style={{ position: "relative", left: "-5px" }}>
<Tooltip placement="right" enterTouchDelay="0" title={params.row.robot+" ("+t(params.row.robot_status)+")"}>
<Tooltip placement="right" enterTouchDelay={0} title={params.row.robot+" ("+t(params.row.robot_status)+")"}>
<Badge variant="dot" overlap="circular" badgeContent="" color={this.statusBadgeColor(params.row.robot_status)}>
<Badge overlap="circular" anchorOrigin={{horizontal: 'right', vertical: 'bottom'}} badgeContent={<div style={{position:"relative", left:"11px", top:"2px"}}> {params.row.type == t("Buyer") ? <SendReceiveIcon sx={{transform: "scaleX(-1)",height:"20px",width:"20px"}} color="secondary"/> : <SendReceiveIcon sx={{height:"20px",width:"20px"}} color="primary"/>}</div>}>
<div style={{ width: 45, height: 45 }}>
<Image className='bookAvatar'
<Image className='bookAvatar'
disableError='true'
disableSpinner='true'
color='null'
Expand All @@ -225,15 +225,15 @@ class BookPage extends Component {
);
} },
{ field: 'type', headerName: t("Is"), width: 60, hide:'true'},
{ field: 'amount', headerName: t("Amount"), type: 'number', width: 84,
{ field: 'amount', headerName: t("Amount"), type: 'number', width: 84,
renderCell: (params) => {return (
<Tooltip placement="right" enterTouchDelay="0" title={t(params.row.type)}>
<Tooltip placement="right" enterTouchDelay={0} title={t(params.row.type)}>
<div style={{ cursor: "pointer" }}>{this.amountToString(params.row.amount,params.row.has_range, params.row.min_amount, params.row.max_amount)}</div>
</Tooltip>
)} },
{ field: 'currency', headerName: t("Currency"), width: 85,
{ field: 'currency', headerName: t("Currency"), width: 85,
renderCell: (params) => {return (
// <Tooltip placement="left" enterTouchDelay="0" title={params.row.payment_method}>
// <Tooltip placement="left" enterTouchDelay={0} title={params.row.payment_method}>
<div style={{ cursor: "pointer", display:'flex',alignItems:'center', flexWrap:'wrap'}}>{params.row.currency+" "}{getFlags(params.row.currency)}</div>
// </Tooltip>
)} },
Expand All @@ -248,12 +248,12 @@ class BookPage extends Component {
)} },
{ field: 'premium', headerName: t("Premium"), type: 'number', width: 85,
renderCell: (params) => {return (
<Tooltip placement="left" enterTouchDelay="0" title={pn(params.row.price) + " " +params.row.currency+ "/BTC" }>
<Tooltip placement="left" enterTouchDelay={0} title={pn(params.row.price) + " " +params.row.currency+ "/BTC" }>
<div style={{ cursor: "pointer" }}>{parseFloat(parseFloat(params.row.premium).toFixed(4))+"%" }</div>
</Tooltip>
)} },
]}

components={{
NoRowsOverlay: () => (
<Stack height="100%" alignItems="center" justifyContent="center">
Expand Down Expand Up @@ -347,9 +347,9 @@ class BookPage extends Component {
control={<Checkbox defaultChecked={true} icon={<BuySatsIcon sx={{width:"30px",height:"30px"}} color="inherit"/>} checkedIcon={<BuySatsCheckedIcon sx={{width:"30px",height:"30px"}} color="primary"/>}/>}
label={
<div style={{position:"relative",top:"-13px"}}>
{this.props.buyChecked ?
{this.props.buyChecked ?
<Typography variant="caption" color="primary"><b>{t("Buy")}</b></Typography>
:
:
<Typography variant="caption" color="text.secondary">{t("Buy")}</Typography>
}
</div>
Expand All @@ -363,9 +363,9 @@ class BookPage extends Component {
control={<Checkbox defaultChecked={true} icon={<SellSatsIcon sx={{width:"30px",height:"30px"}} color="inherit"/>} checkedIcon={<SellSatsCheckedIcon sx={{width:"30px",height:"30px"}} color="secondary"/>}/>}
label={
<div style={{position:"relative",top:"-13px"}}>
{this.props.sellChecked ?
{this.props.sellChecked ?
<Typography variant="caption" color="secondary"><b>{t("Sell")}</b></Typography>
:
:
<Typography variant="caption" color="text.secondary">{t("Sell")}</Typography>
}
</div>
Expand All @@ -389,39 +389,39 @@ class BookPage extends Component {
//autoWidth={true}
sx={{width:120}}
label={t("Select Payment Currency")}
required="true"
value={this.props.currency}
required={true}
value={this.props.currency}
inputProps={{
style: {textAlign:"center"}
}}
onChange={this.handleCurrencyChange}
> <MenuItem value={0}><div style={{display:'flex',alignItems:'center', flexWrap:'wrap'}}>{getFlags('ANY')}{" "+t("ANY_currency")}</div></MenuItem>
{
Object.entries(currencyDict)
.map( ([key, value]) => <MenuItem value={parseInt(key)}><div style={{display:'flex',alignItems:'center', flexWrap:'wrap'}}>{getFlags(value)}{" "+value}</div></MenuItem> )
.map( ([key, value]) => <MenuItem key={key} value={parseInt(key)}><div style={{display:'flex',alignItems:'center', flexWrap:'wrap'}}>{getFlags(value)}{" "+value}</div></MenuItem> )
}
</Select>
</FormControl>
</Grid>
{ this.props.notFound ? "" :
<Grid item xs={12} align="center">
<Typography component="h5" variant="h5">
{this.props.type == 0 ?
t("You are SELLING BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode})
:
(this.props.type == 1 ?
{this.props.type == 0 ?
t("You are SELLING BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode})
:
(this.props.type == 1 ?
t("You are BUYING BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode})
:
t("You are looking at all")
)
}
}
</Typography>
</Grid>
}

{ this.props.notFound ?
<this.NoOrdersFound/>
:
:
<Grid item xs={12} align="center">
{/* Desktop Book */}
<MediaQuery minWidth={930}>
Expand All @@ -445,7 +445,7 @@ class BookPage extends Component {
</Grid>
</Grid>
);
};
}
}

export default withTranslation()(BookPage);
export default withTranslation()(BookPage);
27 changes: 16 additions & 11 deletions frontend/src/components/BottomBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ class BottomBar extends Component {
showRewardsSpinner: false,
withdrawn: false,
};
}

componentDidMount() {
console.log("mount fernando");
this.getInfo();
}
}

getInfo() {
this.setState(null)
Expand Down Expand Up @@ -335,7 +339,7 @@ class BottomBar extends Component {
size='small'
InputProps={{
endAdornment:
<Tooltip disableHoverListener enterTouchDelay="0" title={t("Copied!")}>
<Tooltip disableHoverListener enterTouchDelay={0} title={t("Copied!")}>
<IconButton onClick= {()=>navigator.clipboard.writeText(this.props.token)}>
<ContentCopy />
</IconButton>
Expand Down Expand Up @@ -370,7 +374,7 @@ class BottomBar extends Component {
size='small'
InputProps={{
endAdornment:
<Tooltip disableHoverListener enterTouchDelay="0" title={t("Copied!")}>
<Tooltip disableHoverListener enterTouchDelay={0} title={t("Copied!")}>
<IconButton onClick= {()=>navigator.clipboard.writeText('http://'+this.getHost()+'/ref/'+this.state.referral_code)}>
<ContentCopy />
</IconButton>
Expand Down Expand Up @@ -542,7 +546,7 @@ bottomBarDesktop =()=>{
<this.LangSelect/>
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show community and support links")}>
<Tooltip enterTouchDelay={250} title={t("Show community and support links")}>
<IconButton
color="primary"
aria-label="Community"
Expand All @@ -552,7 +556,7 @@ bottomBarDesktop =()=>{
</Tooltip>
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show stats for nerds")}>
<Tooltip enterTouchDelay={250} title={t("Show stats for nerds")}>
<IconButton color="primary"
aria-label="Stats for Nerds"
onClick={this.handleClickOpenStatsForNerds} >
Expand Down Expand Up @@ -735,7 +739,7 @@ bottomBarPhone =()=>{
</Grid>

<Grid item xs={1.6} align="center">
<Tooltip enterTouchDelay="300" title={t("Number of public BUY orders")}>
<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 />
Expand All @@ -745,7 +749,7 @@ bottomBarPhone =()=>{
</Grid>

<Grid item xs={1.6} align="center">
<Tooltip enterTouchDelay="300" title={t("Number of public SELL orders")}>
<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 />
Expand All @@ -755,7 +759,7 @@ bottomBarPhone =()=>{
</Grid>

<Grid item xs={1.6} align="center">
<Tooltip enterTouchDelay="300" title={t("Today active robots")}>
<Tooltip enterTouchDelay={300} title={t("Today active robots")}>
<IconButton onClick={this.handleClickOpenExchangeSummary} >
<Badge badgeContent={this.state.active_robots_today} color="action">
<SmartToyIcon />
Expand All @@ -765,7 +769,7 @@ bottomBarPhone =()=>{
</Grid>

<Grid item xs={1.8} align="center">
<Tooltip enterTouchDelay="300" title={t("24h non-KYC bitcoin premium")}>
<Tooltip enterTouchDelay={300} title={t("24h non-KYC bitcoin premium")}>
<IconButton onClick={this.handleClickOpenExchangeSummary} >
<Badge badgeContent={this.state.last_day_nonkyc_btc_premium+"%"} color="action">
<PriceChangeIcon />
Expand All @@ -779,7 +783,7 @@ bottomBarPhone =()=>{
<this.LangSelect/>
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show community and support links")}>
<Tooltip enterTouchDelay={250} title={t("Show community and support links")}>
<IconButton
color="primary"
aria-label="Community"
Expand All @@ -789,7 +793,7 @@ bottomBarPhone =()=>{
</Tooltip>
</Grid>
<Grid item xs={3}>
<Tooltip enterTouchDelay="250" title={t("Show stats for nerds")}>
<Tooltip enterTouchDelay={250} title={t("Show stats for nerds")}>
<IconButton color="primary"
aria-label="Stats for Nerds"
onClick={this.handleClickOpenStatsForNerds} >
Expand Down Expand Up @@ -818,4 +822,5 @@ bottomBarPhone =()=>{
)
}
}

export default withTranslation()(BottomBar);
Loading

0 comments on commit 67b68f5

Please sign in to comment.