Run npm run lint:fix

Still many linting errors to fix manually
This commit is contained in:
Reckless_Satoshi 2022-09-09 10:33:29 -07:00
parent 14487a9c2d
commit 822281e467
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
32 changed files with 185 additions and 171 deletions

View File

@ -36,4 +36,7 @@ jobs:
uses: wearerequired/lint-action@v2 uses: wearerequired/lint-action@v2
with: with:
prettier: true prettier: true
prettier_dir: frontend prettier_dir: frontend
# Many linting errors
# eslint: true
# eslint_dir: frontend

View File

@ -83,4 +83,4 @@
"webln": "^0.3.0", "webln": "^0.3.0",
"websocket": "^1.0.34" "websocket": "^1.0.34"
} }
} }

View File

@ -9,7 +9,7 @@ import { LearnDialog } from './Dialogs';
import { I18nextProvider } from 'react-i18next'; import { I18nextProvider } from 'react-i18next';
import i18n from './i18n'; import i18n from './i18n';
//Icons // Icons
import DarkModeIcon from '@mui/icons-material/DarkMode'; import DarkModeIcon from '@mui/icons-material/DarkMode';
import LightModeIcon from '@mui/icons-material/LightMode'; import LightModeIcon from '@mui/icons-material/LightMode';
import SchoolIcon from '@mui/icons-material/School'; import SchoolIcon from '@mui/icons-material/School';

View File

@ -232,9 +232,9 @@ export default function AutocompletePayments(props) {
const [val, setVal] = useState(); const [val, setVal] = useState();
function optionsToString(newValue) { function optionsToString(newValue) {
var str = ''; let str = '';
var arrayLength = newValue.length; const arrayLength = newValue.length;
for (var i = 0; i < arrayLength; i++) { for (let i = 0; i < arrayLength; i++) {
str += newValue[i].name + ' '; str += newValue[i].name + ' ';
} }
return str.slice(0, -1); return str.slice(0, -1);
@ -242,7 +242,7 @@ export default function AutocompletePayments(props) {
function handleAddNew(inputProps) { function handleAddNew(inputProps) {
paymentMethods.push({ name: inputProps.value, icon: 'custom' }); paymentMethods.push({ name: inputProps.value, icon: 'custom' });
var a = value.push({ name: inputProps.value, icon: 'custom' }); const a = value.push({ name: inputProps.value, icon: 'custom' });
setVal(() => ''); setVal(() => '');
if (a || a == null) { if (a || a == null) {
@ -274,7 +274,7 @@ export default function AutocompletePayments(props) {
{value.map((option, index) => ( {value.map((option, index) => (
<StyledTag label={t(option.name)} icon={option.icon} {...getTagProps({ index })} /> <StyledTag label={t(option.name)} icon={option.icon} {...getTagProps({ index })} />
))} ))}
<input {...getInputProps()} value={val ? val : ''} /> <input {...getInputProps()} value={val || ''} />
</InputWrapper> </InputWrapper>
</div> </div>
</Tooltip> </Tooltip>
@ -320,7 +320,7 @@ export default function AutocompletePayments(props) {
) : null ) : null
) : null} ) : null}
</Listbox> </Listbox>
) : //Here goes what happens if there is no groupedOptions ) : // Here goes what happens if there is no groupedOptions
getInputProps().value.length > 0 ? ( getInputProps().value.length > 0 ? (
<Listbox {...getListboxProps()}> <Listbox {...getListboxProps()}>
<Button fullWidth={true} onClick={() => handleAddNew(getInputProps())}> <Button fullWidth={true} onClick={() => handleAddNew(getInputProps())}>

View File

@ -67,9 +67,9 @@ class BookPage extends Component {
}; };
handleCurrencyChange = (e) => { handleCurrencyChange = (e) => {
var currency = e.target.value; const currency = e.target.value;
this.props.setAppState({ this.props.setAppState({
currency: currency, currency,
bookCurrencyCode: this.getCurrencyCode(currency), bookCurrencyCode: this.getCurrencyCode(currency),
}); });
}; };
@ -437,7 +437,7 @@ class BookPage extends Component {
}; };
handleTypeChange = (buyChecked, sellChecked) => { handleTypeChange = (buyChecked, sellChecked) => {
this.props.setAppState({ buyChecked: buyChecked, sellChecked: sellChecked }); this.props.setAppState({ buyChecked, sellChecked });
if (buyChecked & sellChecked || !buyChecked & !sellChecked) { if (buyChecked & sellChecked || !buyChecked & !sellChecked) {
var type = 2; var type = 2;
@ -446,12 +446,12 @@ class BookPage extends Component {
} else if (sellChecked) { } else if (sellChecked) {
var type = 0; var type = 0;
} }
this.props.setAppState({ type: type }); this.props.setAppState({ type });
}; };
handleClickBuy = (e) => { handleClickBuy = (e) => {
var buyChecked = e.target.checked; const buyChecked = e.target.checked;
var sellChecked = this.props.sellChecked; const sellChecked = this.props.sellChecked;
this.handleTypeChange(buyChecked, sellChecked); this.handleTypeChange(buyChecked, sellChecked);
}; };
@ -460,8 +460,8 @@ class BookPage extends Component {
}; };
handleClickSell = (e) => { handleClickSell = (e) => {
var buyChecked = this.props.buyChecked; const buyChecked = this.props.buyChecked;
var sellChecked = e.target.checked; const sellChecked = e.target.checked;
this.handleTypeChange(buyChecked, sellChecked); this.handleTypeChange(buyChecked, sellChecked);
}; };
@ -659,7 +659,7 @@ class BookPage extends Component {
: t('and use')} : t('and use')}
</FormHelperText> </FormHelperText>
<Select <Select
//autoWidth={true} // autoWidth={true}
sx={{ width: 120 }} sx={{ width: 120 }}
label={t('Select Payment Currency')} label={t('Select Payment Currency')}
required={true} required={true}

View File

@ -99,6 +99,7 @@ class BottomBar extends Component {
handleClickOpenCommunity = () => { handleClickOpenCommunity = () => {
this.setState({ openCommuniy: true }); this.setState({ openCommuniy: true });
}; };
handleClickCloseCommunity = () => { handleClickCloseCommunity = () => {
this.setState({ openCommuniy: false }); this.setState({ openCommuniy: false });
}; };
@ -107,6 +108,7 @@ class BottomBar extends Component {
this.getInfo(); this.getInfo();
this.setState({ openProfile: true, profileShown: true }); this.setState({ openProfile: true, profileShown: true });
}; };
handleClickCloseProfile = () => { handleClickCloseProfile = () => {
this.setState({ openProfile: false }); this.setState({ openProfile: false });
}; };
@ -130,8 +132,8 @@ class BottomBar extends Component {
(data) => (data) =>
this.setState({ this.setState({
badInvoice: data.bad_invoice, badInvoice: data.bad_invoice,
openClaimRewards: data.successful_withdrawal ? false : true, openClaimRewards: !data.successful_withdrawal,
withdrawn: data.successful_withdrawal ? true : false, withdrawn: !!data.successful_withdrawal,
showRewardsSpinner: false, showRewardsSpinner: false,
}) & }) &
this.props.setAppState({ this.props.setAppState({
@ -145,7 +147,7 @@ class BottomBar extends Component {
const requestOptions = { const requestOptions = {
method: 'PUT', method: 'PUT',
headers: { 'Content-Type': 'application/json', 'X-CSRFToken': getCookie('csrftoken') }, headers: { 'Content-Type': 'application/json', 'X-CSRFToken': getCookie('csrftoken') },
body: JSON.stringify({ wantsStealth: wantsStealth }), body: JSON.stringify({ wantsStealth }),
}; };
fetch('/api/stealth/', requestOptions) fetch('/api/stealth/', requestOptions)
.then((response) => response.json()) .then((response) => response.json())
@ -153,7 +155,7 @@ class BottomBar extends Component {
}; };
getHost() { getHost() {
var url = const url =
window.location != window.parent.location window.location != window.parent.location
? this.getHost(document.referrer) ? this.getHost(document.referrer)
: document.location.href; : document.location.href;
@ -170,15 +172,13 @@ class BottomBar extends Component {
bottomBarDesktop = () => { bottomBarDesktop = () => {
const { t } = this.props; const { t } = this.props;
var hasRewards = this.props.earnedRewards > 0 ? true : false; const hasRewards = this.props.earnedRewards > 0;
var hasOrder = const hasOrder =
(this.props.activeOrderId > 0) & !this.state.profileShown & this.props.avatarLoaded !!((this.props.activeOrderId > 0) & !this.state.profileShown & this.props.avatarLoaded);
? true
: false;
const fontSize = this.props.theme.typography.fontSize; const fontSize = this.props.theme.typography.fontSize;
const fontSizeFactor = fontSize / 14; // default fontSize is 14 const fontSizeFactor = fontSize / 14; // default fontSize is 14
const typographyProps = { const typographyProps = {
primaryTypographyProps: { fontSize: fontSize }, primaryTypographyProps: { fontSize },
secondaryTypographyProps: { fontSize: (fontSize * 12) / 14 }, secondaryTypographyProps: { fontSize: (fontSize * 12) / 14 },
}; };
return ( return (
@ -355,6 +355,7 @@ class BottomBar extends Component {
</Paper> </Paper>
); );
}; };
handleChangeLang = (e) => { handleChangeLang = (e) => {
const { i18n } = this.props; const { i18n } = this.props;
i18n.changeLanguage(e.target.value); i18n.changeLanguage(e.target.value);
@ -473,17 +474,16 @@ class BottomBar extends Component {
} }
this.setState({ openExchangeSummary: true }); this.setState({ openExchangeSummary: true });
}; };
handleClickCloseExchangeSummary = () => { handleClickCloseExchangeSummary = () => {
this.setState({ openExchangeSummary: false }); this.setState({ openExchangeSummary: false });
}; };
bottomBarPhone = () => { bottomBarPhone = () => {
const { t } = this.props; const { t } = this.props;
var hasRewards = this.props.earnedRewards > 0 ? true : false; const hasRewards = this.props.earnedRewards > 0;
var hasOrder = const hasOrder =
(this.state.active_order_id > 0) & !this.state.profileShown & this.props.avatarLoaded !!((this.state.active_order_id > 0) & !this.state.profileShown & this.props.avatarLoaded);
? true
: false;
return ( return (
<Paper elevation={6} style={{ height: 40 }}> <Paper elevation={6} style={{ height: 40 }}>
<Grid container> <Grid container>

View File

@ -62,7 +62,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
useEffect(() => { useEffect(() => {
if (Object.keys(limits).length === 0) { if (Object.keys(limits).length === 0) {
fetch('/api/limits/') fetch('/api/limits/')
.then((response) => response.json()) .then(async (response) => await response.json())
.then((data) => { .then((data) => {
setAppState({ limits: data }); setAppState({ limits: data });
}); });
@ -110,7 +110,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
}; };
const generateSeries: () => void = () => { const generateSeries: () => void = () => {
let sortedOrders: Order[] = const sortedOrders: Order[] =
xType === 'base_amount' xType === 'base_amount'
? enrichedOrders.sort( ? enrichedOrders.sort(
(order1, order2) => (order1?.base_amount || 0) - (order2?.base_amount || 0), (order1, order2) => (order1?.base_amount || 0) - (order2?.base_amount || 0),
@ -158,7 +158,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
// Order Point // Order Point
x: xType === 'base_amount' ? order.base_amount : order.premium, x: xType === 'base_amount' ? order.base_amount : order.premium,
y: sumOrders, y: sumOrders,
order: order, order,
}, },
]; ];

View File

@ -37,7 +37,7 @@ function CredentialTextfield(props) {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<Tooltip disableHoverListener enterTouchDelay={0} title={props.copiedTitle}> <Tooltip disableHoverListener enterTouchDelay={0} title={props.copiedTitle}>
<IconButton onClick={() => copyToClipboard(props.value)}> <IconButton onClick={async () => await copyToClipboard(props.value)}>
<ContentCopy /> <ContentCopy />
</IconButton> </IconButton>
</Tooltip> </Tooltip>
@ -49,7 +49,7 @@ function CredentialTextfield(props) {
); );
} }
type Props = { interface Props {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
orderId: number; orderId: number;
@ -59,7 +59,7 @@ type Props = {
peer_pub_key: string; peer_pub_key: string;
passphrase: string; passphrase: string;
onClickBack: () => void; onClickBack: () => void;
}; }
const AuditPGPDialog = ({ const AuditPGPDialog = ({
open, open,
@ -149,7 +149,7 @@ const AuditPGPDialog = ({
own_public_key: own_pub_key, own_public_key: own_pub_key,
peer_public_key: peer_pub_key, peer_public_key: peer_pub_key,
encrypted_private_key: own_enc_priv_key, encrypted_private_key: own_enc_priv_key,
passphrase: passphrase, passphrase,
}) })
} }
> >

View File

@ -19,10 +19,10 @@ import TwitterIcon from '@mui/icons-material/Twitter';
import RedditIcon from '@mui/icons-material/Reddit'; import RedditIcon from '@mui/icons-material/Reddit';
import Flags from 'country-flag-icons/react/3x2'; import Flags from 'country-flag-icons/react/3x2';
type Props = { interface Props {
isOpen: boolean; isOpen: boolean;
handleClickCloseCommunity: () => void; handleClickCloseCommunity: () => void;
}; }
const CommunityDialog = ({ isOpen, handleClickCloseCommunity }: Props): JSX.Element => { const CommunityDialog = ({ isOpen, handleClickCloseCommunity }: Props): JSX.Element => {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -23,7 +23,7 @@ import LinkIcon from '@mui/icons-material/Link';
import { pn } from '../../utils/prettyNumbers'; import { pn } from '../../utils/prettyNumbers';
type Props = { interface Props {
isOpen: boolean; isOpen: boolean;
handleClickCloseExchangeSummary: () => void; handleClickCloseExchangeSummary: () => void;
numPublicBuyOrders: number; numPublicBuyOrders: number;
@ -34,7 +34,7 @@ type Props = {
makerFee: number; makerFee: number;
takerFee: number; takerFee: number;
swapFeeRate: number; swapFeeRate: number;
}; }
const ExchangeSummaryDialog = ({ const ExchangeSummaryDialog = ({
isOpen, isOpen,

View File

@ -18,11 +18,11 @@ import MediaQuery from 'react-responsive';
// Icons // Icons
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
type Props = { interface Props {
maxAmount: string; maxAmount: string;
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
}; }
const InfoDialog = ({ maxAmount, open, onClose }: Props): JSX.Element => { const InfoDialog = ({ maxAmount, open, onClose }: Props): JSX.Element => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -148,7 +148,7 @@ const InfoDialog = ({ maxAmount, open, onClose }: Props): JSX.Element => {
<p> <p>
{t( {t(
'Maximum single trade size is {{maxAmount}} Satoshis to minimize lightning routing failure. There is no limits to the number of trades per day. A robot can only have one order at a time. However, you can use multiple robots simultaneously in different browsers (remember to back up your robot tokens!).', 'Maximum single trade size is {{maxAmount}} Satoshis to minimize lightning routing failure. There is no limits to the number of trades per day. A robot can only have one order at a time. However, you can use multiple robots simultaneously in different browsers (remember to back up your robot tokens!).',
{ maxAmount: maxAmount }, { maxAmount },
)}{' '} )}{' '}
</p> </p>
</Typography> </Typography>

View File

@ -10,10 +10,10 @@ import {
Link, Link,
} from '@mui/material'; } from '@mui/material';
type Props = { interface Props {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
}; }
const LearnDialog = ({ open, onClose }: Props): JSX.Element => { const LearnDialog = ({ open, onClose }: Props): JSX.Element => {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -10,10 +10,10 @@ import {
} from '@mui/material'; } from '@mui/material';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
type Props = { interface Props {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
}; }
const NoRobotDialog = ({ open, onClose }: Props): JSX.Element => { const NoRobotDialog = ({ open, onClose }: Props): JSX.Element => {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -37,7 +37,7 @@ import { getCookie } from '../../utils/cookies';
import { copyToClipboard } from '../../utils/clipboard'; import { copyToClipboard } from '../../utils/clipboard';
import { getWebln } from '../../utils/webln'; import { getWebln } from '../../utils/webln';
type Props = { interface Props {
isOpen: boolean; isOpen: boolean;
handleClickCloseProfile: () => void; handleClickCloseProfile: () => void;
nickname: string; nickname: string;
@ -53,7 +53,7 @@ type Props = {
stealthInvoices: boolean; stealthInvoices: boolean;
handleSetStealthInvoice: (stealth: boolean) => void; handleSetStealthInvoice: (stealth: boolean) => void;
setAppState: (state: any) => void; // TODO: move to a ContextProvider setAppState: (state: any) => void; // TODO: move to a ContextProvider
}; }
const ProfileDialog = ({ const ProfileDialog = ({
isOpen, isOpen,
@ -330,7 +330,7 @@ const ProfileDialog = ({
<Grid item xs={3}> <Grid item xs={3}>
<Button <Button
disabled={earnedRewards === 0 ? true : false} disabled={earnedRewards === 0}
onClick={() => setOpenClaimRewards(true)} onClick={() => setOpenClaimRewards(true)}
variant='contained' variant='contained'
size='small' size='small'
@ -345,8 +345,8 @@ const ProfileDialog = ({
<Grid container style={{ display: 'flex', alignItems: 'stretch' }}> <Grid container style={{ display: 'flex', alignItems: 'stretch' }}>
<Grid item style={{ display: 'flex', maxWidth: 160 }}> <Grid item style={{ display: 'flex', maxWidth: 160 }}>
<TextField <TextField
error={badInvoice ? true : false} error={!!badInvoice}
helperText={badInvoice ? badInvoice : ''} helperText={badInvoice || ''}
label={t('Invoice for {{amountSats}} Sats', { label={t('Invoice for {{amountSats}} Sats', {
amountSats: earnedRewards, amountSats: earnedRewards,
})} })}
@ -375,7 +375,7 @@ const ProfileDialog = ({
<Grid item alignItems='stretch' style={{ display: 'flex', maxWidth: 240 }}> <Grid item alignItems='stretch' style={{ display: 'flex', maxWidth: 240 }}>
<Button <Button
sx={{ maxHeight: 38, minWidth: 230 }} sx={{ maxHeight: 38, minWidth: 230 }}
onClick={(e) => handleWeblnInvoiceClicked(e)} onClick={async (e) => await handleWeblnInvoiceClicked(e)}
variant='contained' variant='contained'
color='primary' color='primary'
size='small' size='small'

View File

@ -25,7 +25,7 @@ import { AmbossIcon, BitcoinSignIcon } from '../Icons';
import { pn } from '../../utils/prettyNumbers'; import { pn } from '../../utils/prettyNumbers';
type Props = { interface Props {
isOpen: boolean; isOpen: boolean;
handleClickCloseStatsForNerds: () => void; handleClickCloseStatsForNerds: () => void;
lndVersion: string; lndVersion: string;
@ -37,7 +37,7 @@ type Props = {
robosatsRunningCommitHash: string; robosatsRunningCommitHash: string;
lastDayVolume: number; lastDayVolume: number;
lifetimeVolume: number; lifetimeVolume: number;
}; }
const StatsDialog = ({ const StatsDialog = ({
isOpen, isOpen,

View File

@ -15,14 +15,14 @@ import {
import { getCookie } from '../../utils/cookies'; import { getCookie } from '../../utils/cookies';
import ContentCopy from '@mui/icons-material/ContentCopy'; import ContentCopy from '@mui/icons-material/ContentCopy';
type Props = { interface Props {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
copyIconColor: string; copyIconColor: string;
onClickCopy: () => void; onClickCopy: () => void;
onClickBack: () => void; onClickBack: () => void;
onClickDone: () => void; onClickDone: () => void;
}; }
const StoreTokenDialog = ({ const StoreTokenDialog = ({
open, open,

View File

@ -132,9 +132,7 @@ class Chat extends Component {
scrollNow: true, scrollNow: true,
waitingEcho: waitingEcho:
this.state.waitingEcho == true this.state.waitingEcho == true
? decryptedData.decryptedMessage == this.state.lastSent ? decryptedData.decryptedMessage != this.state.lastSent
? false
: true
: false, : false,
lastSent: lastSent:
decryptedData.decryptedMessage == this.state.lastSent decryptedData.decryptedMessage == this.state.lastSent

View File

@ -3,9 +3,9 @@ import Flags from 'country-flag-icons/react/3x2';
import SwapCallsIcon from '@mui/icons-material/SwapCalls'; import SwapCallsIcon from '@mui/icons-material/SwapCalls';
import { GoldIcon, EarthIcon } from '../Icons'; import { GoldIcon, EarthIcon } from '../Icons';
type Props = { interface Props {
code: string; code: string;
}; }
const FlagWithProps = ({ code }: Props): JSX.Element => { const FlagWithProps = ({ code }: Props): JSX.Element => {
const defaultProps = { const defaultProps = {

View File

@ -2,10 +2,10 @@ import React, { useState, useEffect } from 'react';
import { Box, LinearProgress } from '@mui/material'; import { Box, LinearProgress } from '@mui/material';
import { calcTimeDelta } from 'react-countdown'; import { calcTimeDelta } from 'react-countdown';
type Props = { interface Props {
expiresAt: string; expiresAt: string;
totalSecsExp: number; totalSecsExp: number;
}; }
const LinearDeterminate = ({ expiresAt, totalSecsExp }: Props): JSX.Element => { const LinearDeterminate = ({ expiresAt, totalSecsExp }: Props): JSX.Element => {
const [progress, setProgress] = useState<number>(0); const [progress, setProgress] = useState<number>(0);

View File

@ -42,7 +42,7 @@ import FlagWithProps from './FlagWithProps';
import AutocompletePayments from './AutocompletePayments'; import AutocompletePayments from './AutocompletePayments';
import currencyDict from '../../static/assets/currencies.json'; import currencyDict from '../../static/assets/currencies.json';
//icons // icons
import LockIcon from '@mui/icons-material/Lock'; import LockIcon from '@mui/icons-material/Lock';
import HourglassTopIcon from '@mui/icons-material/HourglassTop'; import HourglassTopIcon from '@mui/icons-material/HourglassTop';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
@ -112,13 +112,13 @@ class MakerPage extends Component {
loadingLimits: false, loadingLimits: false,
minAmount: this.state.amount minAmount: this.state.amount
? parseFloat((this.state.amount / 2).toPrecision(2)) ? parseFloat((this.state.amount / 2).toPrecision(2))
: parseFloat(Number(data[this.state.currency]['max_amount'] * 0.25).toPrecision(2)), : parseFloat(Number(data[this.state.currency].max_amount * 0.25).toPrecision(2)),
maxAmount: this.state.amount maxAmount: this.state.amount
? this.state.amount ? this.state.amount
: parseFloat(Number(data[this.state.currency]['max_amount'] * 0.75).toPrecision(2)), : parseFloat(Number(data[this.state.currency].max_amount * 0.75).toPrecision(2)),
minTradeSats: data['1000']['min_amount'] * 100000000, minTradeSats: data['1000'].min_amount * 100000000,
maxTradeSats: data['1000']['max_amount'] * 100000000, maxTradeSats: data['1000'].max_amount * 100000000,
maxBondlessSats: data['1000']['max_bondless_amount'] * 100000000, maxBondlessSats: data['1000'].max_bondless_amount * 100000000,
}), }),
); );
} }
@ -128,12 +128,12 @@ class MakerPage extends Component {
minAmount: this.state.amount minAmount: this.state.amount
? parseFloat((this.state.amount / 2).toPrecision(2)) ? parseFloat((this.state.amount / 2).toPrecision(2))
: parseFloat( : parseFloat(
Number(this.state.limits[this.state.currency]['max_amount'] * 0.25).toPrecision(2), Number(this.state.limits[this.state.currency].max_amount * 0.25).toPrecision(2),
), ),
maxAmount: this.state.amount maxAmount: this.state.amount
? this.state.amount ? this.state.amount
: parseFloat( : parseFloat(
Number(this.state.limits[this.state.currency]['max_amount'] * 0.75).toPrecision(2), Number(this.state.limits[this.state.currency].max_amount * 0.75).toPrecision(2),
), ),
}); });
}; };
@ -153,15 +153,16 @@ class MakerPage extends Component {
this.props.setAppState({ this.props.setAppState({
// maker and book page type values 0:1 are reversed // maker and book page type values 0:1 are reversed
type: e.target.value == 1 ? 0 : 1, type: e.target.value == 1 ? 0 : 1,
buyChecked: e.target.value == 0 ? true : false, buyChecked: e.target.value == 0,
sellChecked: e.target.value == 1 ? true : false, sellChecked: e.target.value == 1,
}); });
}; };
handleCurrencyChange = (e) => { handleCurrencyChange = (e) => {
var currencyCode = this.getCurrencyCode(e.target.value); const currencyCode = this.getCurrencyCode(e.target.value);
this.setState({ this.setState({
currency: e.target.value, currency: e.target.value,
currencyCode: currencyCode, currencyCode,
}); });
this.props.setAppState({ this.props.setAppState({
type: e.target.value, type: e.target.value,
@ -171,24 +172,27 @@ class MakerPage extends Component {
if (this.state.enableAmountRange) { if (this.state.enableAmountRange) {
this.setState({ this.setState({
minAmount: parseFloat( minAmount: parseFloat(
Number(this.state.limits[e.target.value]['max_amount'] * 0.25).toPrecision(2), Number(this.state.limits[e.target.value].max_amount * 0.25).toPrecision(2),
), ),
maxAmount: parseFloat( maxAmount: parseFloat(
Number(this.state.limits[e.target.value]['max_amount'] * 0.75).toPrecision(2), Number(this.state.limits[e.target.value].max_amount * 0.75).toPrecision(2),
), ),
}); });
} }
}; };
handleAmountChange = (e) => { handleAmountChange = (e) => {
this.setState({ this.setState({
amount: e.target.value, amount: e.target.value,
}); });
}; };
handleMinAmountChange = (e) => { handleMinAmountChange = (e) => {
this.setState({ this.setState({
minAmount: parseFloat(Number(e.target.value).toPrecision(e.target.value < 100 ? 2 : 3)), minAmount: parseFloat(Number(e.target.value).toPrecision(e.target.value < 100 ? 2 : 3)),
}); });
}; };
handleMaxAmountChange = (e) => { handleMaxAmountChange = (e) => {
this.setState({ this.setState({
maxAmount: parseFloat(Number(e.target.value).toPrecision(e.target.value < 100 ? 2 : 3)), maxAmount: parseFloat(Number(e.target.value).toPrecision(e.target.value < 100 ? 2 : 3)),
@ -196,12 +200,12 @@ class MakerPage extends Component {
}; };
handleRangeAmountChange = (e, newValue, activeThumb) => { handleRangeAmountChange = (e, newValue, activeThumb) => {
var maxAmount = this.getMaxAmount(); const maxAmount = this.getMaxAmount();
var minAmount = this.getMinAmount(); const minAmount = this.getMinAmount();
var lowerValue = e.target.value[0]; let lowerValue = e.target.value[0];
var upperValue = e.target.value[1]; let upperValue = e.target.value[1];
var minRange = this.minRangeAmountMultiple; const minRange = this.minRangeAmountMultiple;
var maxRange = this.maxRangeAmountMultiple; const maxRange = this.maxRangeAmountMultiple;
if (lowerValue > maxAmount / minRange) { if (lowerValue > maxAmount / minRange) {
lowerValue = maxAmount / minRange; lowerValue = maxAmount / minRange;
@ -245,14 +249,14 @@ class MakerPage extends Component {
handlePremiumChange = (e) => { handlePremiumChange = (e) => {
const { t } = this.props; const { t } = this.props;
var max = 999; const max = 999;
var min = -100; const min = -100;
var premium = e.target.value; let premium = e.target.value;
if (e.target.value > 999) { if (e.target.value > 999) {
var bad_premium = t('Must be less than {{max}}%', { max: max }); var bad_premium = t('Must be less than {{max}}%', { max });
} }
if (e.target.value <= -100) { if (e.target.value <= -100) {
var bad_premium = t('Must be more than {{min}}%', { min: min }); var bad_premium = t('Must be more than {{min}}%', { min });
} }
if (premium == '') { if (premium == '') {
@ -261,7 +265,7 @@ class MakerPage extends Component {
premium = Number(Math.round(premium + 'e' + 2) + 'e-' + 2); premium = Number(Math.round(premium + 'e' + 2) + 'e-' + 2);
} }
this.setState({ this.setState({
premium: premium, premium,
badPremium: bad_premium, badPremium: bad_premium,
}); });
}; };
@ -280,6 +284,7 @@ class MakerPage extends Component {
badSatoshis: bad_sats, badSatoshis: bad_sats,
}); });
}; };
handleClickRelative = (e) => { handleClickRelative = (e) => {
this.setState({ this.setState({
is_explicit: false, is_explicit: false,
@ -345,7 +350,7 @@ class MakerPage extends Component {
Number(this.state.amount / (this.state.satoshis / 100000000)).toPrecision(5), Number(this.state.amount / (this.state.satoshis / 100000000)).toPrecision(5),
); );
} else if (!this.state.is_explicit) { } else if (!this.state.is_explicit) {
var price = this.state.limits[this.state.currency]['price']; const price = this.state.limits[this.state.currency].price;
return parseFloat(Number(price * (1 + this.state.premium / 100)).toPrecision(5)); return parseFloat(Number(price * (1 + this.state.premium / 100)).toPrecision(5));
} }
return '...'; return '...';
@ -440,11 +445,9 @@ class MakerPage extends Component {
disabled={this.state.enableAmountRange} disabled={this.state.enableAmountRange}
variant={this.state.enableAmountRange ? 'filled' : 'outlined'} variant={this.state.enableAmountRange ? 'filled' : 'outlined'}
error={ error={
(this.state.amount < this.getMinAmount() || !!((this.state.amount < this.getMinAmount() ||
this.state.amount > this.getMaxAmount()) & this.state.amount > this.getMaxAmount()) &
(this.state.amount != '') (this.state.amount != ''))
? true
: false
} }
helperText={ helperText={
(this.state.amount < this.getMinAmount()) & (this.state.amount != '') (this.state.amount < this.getMinAmount()) & (this.state.amount != '')
@ -549,7 +552,7 @@ class MakerPage extends Component {
<TextField <TextField
sx={{ width: `${240 / 16}em` }} sx={{ width: `${240 / 16}em` }}
label={t('Satoshis')} label={t('Satoshis')}
error={this.state.badSatoshis ? true : false} error={!!this.state.badSatoshis}
helperText={this.state.badSatoshis} helperText={this.state.badSatoshis}
type='number' type='number'
required={true} required={true}
@ -611,11 +614,11 @@ class MakerPage extends Component {
}; };
handleChangePublicDuration = (date) => { handleChangePublicDuration = (date) => {
let d = new Date(date), const d = new Date(date);
hours = d.getHours(), const hours = d.getHours();
minutes = d.getMinutes(); const minutes = d.getMinutes();
var total_secs = hours * 60 * 60 + minutes * 60; const total_secs = hours * 60 * 60 + minutes * 60;
this.setState({ this.setState({
publicExpiryTime: date, publicExpiryTime: date,
@ -624,11 +627,11 @@ class MakerPage extends Component {
}; };
handleChangeEscrowDuration = (date) => { handleChangeEscrowDuration = (date) => {
let d = new Date(date), const d = new Date(date);
hours = d.getHours(), const hours = d.getHours();
minutes = d.getMinutes(); const minutes = d.getMinutes();
var total_secs = hours * 60 * 60 + minutes * 60; const total_secs = hours * 60 * 60 + minutes * 60;
this.setState({ this.setState({
escrowExpiryTime: date, escrowExpiryTime: date,
@ -641,7 +644,7 @@ class MakerPage extends Component {
var max_amount = null; var max_amount = null;
} else { } else {
var max_amount = var max_amount =
this.state.limits[this.state.currency]['max_amount'] * (1 + this.state.premium / 100); this.state.limits[this.state.currency].max_amount * (1 + this.state.premium / 100);
} }
// times 0.98 to allow a bit of margin with respect to the backend minimum // times 0.98 to allow a bit of margin with respect to the backend minimum
return parseFloat(Number(max_amount * 0.98).toPrecision(2)); return parseFloat(Number(max_amount * 0.98).toPrecision(2));
@ -652,7 +655,7 @@ class MakerPage extends Component {
var min_amount = null; var min_amount = null;
} else { } else {
var min_amount = var min_amount =
this.state.limits[this.state.currency]['min_amount'] * (1 + this.state.premium / 100); this.state.limits[this.state.currency].min_amount * (1 + this.state.premium / 100);
} }
// times 1.1 to allow a bit of margin with respect to the backend minimum // times 1.1 to allow a bit of margin with respect to the backend minimum
return parseFloat(Number(min_amount * 1.1).toPrecision(2)); return parseFloat(Number(min_amount * 1.1).toPrecision(2));
@ -678,6 +681,7 @@ class MakerPage extends Component {
this.state.minAmount * (this.minRangeAmountMultiple - 0.1) > this.state.maxAmount this.state.minAmount * (this.minRangeAmountMultiple - 0.1) > this.state.maxAmount
); );
}; };
maxAmountError = () => { maxAmountError = () => {
return ( return (
this.state.maxAmount > this.getMaxAmount() || this.state.maxAmount > this.getMaxAmount() ||
@ -915,7 +919,7 @@ class MakerPage extends Component {
control={ control={
<Checkbox <Checkbox
disabled disabled
//disabled={this.state.type==0 || this.state.type === null} // disabled={this.state.type==0 || this.state.type === null}
color='secondary' color='secondary'
checked={this.state.allowBondless} checked={this.state.allowBondless}
onChange={() => this.setState({ allowBondless: !this.state.allowBondless })} onChange={() => this.setState({ allowBondless: !this.state.allowBondless })}

View File

@ -75,25 +75,25 @@ class OrderPage extends Component {
// Refresh delays according to Order status // Refresh delays according to Order status
this.statusToDelay = { this.statusToDelay = {
0: 2000, //'Waiting for maker bond' 0: 2000, // 'Waiting for maker bond'
1: 25000, //'Public' 1: 25000, // 'Public'
2: 90000, //'Paused' 2: 90000, // 'Paused'
3: 2000, //'Waiting for taker bond' 3: 2000, // 'Waiting for taker bond'
4: 999999, //'Cancelled' 4: 999999, // 'Cancelled'
5: 999999, //'Expired' 5: 999999, // 'Expired'
6: 6000, //'Waiting for trade collateral and buyer invoice' 6: 6000, // 'Waiting for trade collateral and buyer invoice'
7: 8000, //'Waiting only for seller trade collateral' 7: 8000, // 'Waiting only for seller trade collateral'
8: 8000, //'Waiting only for buyer invoice' 8: 8000, // 'Waiting only for buyer invoice'
9: 10000, //'Sending fiat - In chatroom' 9: 10000, // 'Sending fiat - In chatroom'
10: 10000, //'Fiat sent - In chatroom' 10: 10000, // 'Fiat sent - In chatroom'
11: 30000, //'In dispute' 11: 30000, // 'In dispute'
12: 999999, //'Collaboratively cancelled' 12: 999999, // 'Collaboratively cancelled'
13: 3000, //'Sending satoshis to buyer' 13: 3000, // 'Sending satoshis to buyer'
14: 999999, //'Sucessful trade' 14: 999999, // 'Sucessful trade'
15: 10000, //'Failed lightning network routing' 15: 10000, // 'Failed lightning network routing'
16: 180000, //'Wait for dispute resolution' 16: 180000, // 'Wait for dispute resolution'
17: 180000, //'Maker lost dispute' 17: 180000, // 'Maker lost dispute'
18: 180000, //'Taker lost dispute' 18: 180000, // 'Taker lost dispute'
}; };
} }
@ -107,7 +107,7 @@ class OrderPage extends Component {
newStateVars.status = this.state.status; newStateVars.status = this.state.status;
} }
var otherStateVars = { const otherStateVars = {
amount: newStateVars.amount ? newStateVars.amount : null, amount: newStateVars.amount ? newStateVars.amount : null,
loading: false, loading: false,
delay: this.setDelay(newStateVars.status), delay: this.setDelay(newStateVars.status),
@ -116,7 +116,7 @@ class OrderPage extends Component {
invoice_expired: newStateVars.invoice_expired, // in case invoice had expired, it goes back to null when it is valid again invoice_expired: newStateVars.invoice_expired, // in case invoice had expired, it goes back to null when it is valid again
}; };
var completeStateVars = Object.assign({}, newStateVars, otherStateVars); const completeStateVars = Object.assign({}, newStateVars, otherStateVars);
this.setState(completeStateVars); this.setState(completeStateVars);
}; };
@ -149,6 +149,7 @@ class OrderPage extends Component {
componentWillUnmount() { componentWillUnmount() {
clearInterval(this.interval); clearInterval(this.interval);
} }
tick = () => { tick = () => {
this.getOrderDetails(this.state.orderId); this.getOrderDetails(this.state.orderId);
}; };
@ -189,7 +190,7 @@ class OrderPage extends Component {
headers: { 'Content-Type': 'application/json', 'X-CSRFToken': getCookie('csrftoken') }, headers: { 'Content-Type': 'application/json', 'X-CSRFToken': getCookie('csrftoken') },
body: JSON.stringify({ body: JSON.stringify({
action: 'update_invoice', action: 'update_invoice',
invoice: invoice, invoice,
}), }),
}; };
fetch('/api/order/' + '?order_id=' + this.state.orderId, requestOptions) fetch('/api/order/' + '?order_id=' + this.state.orderId, requestOptions)
@ -204,8 +205,8 @@ class OrderPage extends Component {
// Render a completed state // Render a completed state
return <span> {t('The order has expired')}</span>; return <span> {t('The order has expired')}</span>;
} else { } else {
var col = 'inherit'; let col = 'inherit';
var fraction_left = total / 1000 / this.state.total_secs_exp; const fraction_left = total / 1000 / this.state.total_secs_exp;
// Make orange at 25% of time left // Make orange at 25% of time left
if (fraction_left < 0.25) { if (fraction_left < 0.25) {
col = 'orange'; col = 'orange';
@ -230,8 +231,8 @@ class OrderPage extends Component {
}; };
timerRenderer(seconds) { timerRenderer(seconds) {
var hours = parseInt(seconds / 3600); const hours = parseInt(seconds / 3600);
var minutes = parseInt((seconds - hours * 3600) / 60); const minutes = parseInt((seconds - hours * 3600) / 60);
return ( return (
<span> <span>
{hours > 0 ? hours + 'h' : ''} {minutes > 0 ? zeroPad(minutes) + 'm' : ''}{' '} {hours > 0 ? hours + 'h' : ''} {minutes > 0 ? zeroPad(minutes) + 'm' : ''}{' '}
@ -447,7 +448,7 @@ class OrderPage extends Component {
}; };
getCurrencyCode(val) { getCurrencyCode(val) {
let code = val ? currencyDict[val.toString()] : ''; const code = val ? currencyDict[val.toString()] : '';
return code; return code;
} }
@ -469,6 +470,7 @@ class OrderPage extends Component {
handleClickOpenConfirmCancelDialog = () => { handleClickOpenConfirmCancelDialog = () => {
this.setState({ openCancel: true }); this.setState({ openCancel: true });
}; };
handleClickCloseConfirmCancelDialog = () => { handleClickCloseConfirmCancelDialog = () => {
this.setState({ openCancel: false }); this.setState({ openCancel: false });
}; };
@ -501,6 +503,7 @@ class OrderPage extends Component {
handleClickOpenInactiveMakerDialog = () => { handleClickOpenInactiveMakerDialog = () => {
this.setState({ openInactiveMaker: true }); this.setState({ openInactiveMaker: true });
}; };
handleClickCloseInactiveMakerDialog = () => { handleClickCloseInactiveMakerDialog = () => {
this.setState({ openInactiveMaker: false }); this.setState({ openInactiveMaker: false });
}; };
@ -574,6 +577,7 @@ class OrderPage extends Component {
handleClickOpenCollaborativeCancelDialog = () => { handleClickOpenCollaborativeCancelDialog = () => {
this.setState({ openCollaborativeCancel: true }); this.setState({ openCollaborativeCancel: true });
}; };
handleClickCloseCollaborativeCancelDialog = () => { handleClickCloseCollaborativeCancelDialog = () => {
this.setState({ openCollaborativeCancel: false }); this.setState({ openCollaborativeCancel: false });
}; };

View File

@ -14,8 +14,8 @@ class PaymentText extends Component {
parseText() { parseText() {
const { t } = this.props; const { t } = this.props;
var rows = []; const rows = [];
var custom_methods = this.props.text; let custom_methods = this.props.text;
// Adds icons for each PaymentMethod that matches // Adds icons for each PaymentMethod that matches
methods.forEach((method, i) => { methods.forEach((method, i) => {
if (this.props.text.includes(method.name)) { if (this.props.text.includes(method.name)) {
@ -42,7 +42,7 @@ class PaymentText extends Component {
}); });
// Adds a Custom icon if there are words that do not match // Adds a Custom icon if there are words that do not match
var chars_left = custom_methods const chars_left = custom_methods
.replace(' ', '') .replace(' ', '')
.replace(' ', '') .replace(' ', '')
.replace(' ', '') .replace(' ', '')

View File

@ -80,9 +80,9 @@ class TradeBox extends Component {
stepXofY = () => { stepXofY = () => {
// set y value // set y value
var x = null; let x = null;
var y = null; let y = null;
var status = this.props.data.status; const status = this.props.data.status;
if (this.props.data.is_maker) { if (this.props.data.is_maker) {
y = 5; y = 5;
@ -128,6 +128,7 @@ class TradeBox extends Component {
handleClickOpenConfirmDispute = () => { handleClickOpenConfirmDispute = () => {
this.setState({ openConfirmDispute: true }); this.setState({ openConfirmDispute: true });
}; };
handleClickCloseConfirmDispute = () => { handleClickCloseConfirmDispute = () => {
this.setState({ openConfirmDispute: false }); this.setState({ openConfirmDispute: false });
}; };
@ -186,6 +187,7 @@ class TradeBox extends Component {
handleClickOpenConfirmFiatReceived = () => { handleClickOpenConfirmFiatReceived = () => {
this.setState({ openConfirmFiatReceived: true }); this.setState({ openConfirmFiatReceived: true });
}; };
handleClickCloseConfirmFiatReceived = () => { handleClickCloseConfirmFiatReceived = () => {
this.setState({ openConfirmFiatReceived: false }); this.setState({ openConfirmFiatReceived: false });
}; };
@ -482,6 +484,7 @@ class TradeBox extends Component {
handleClickOpenTelegramDialog = () => { handleClickOpenTelegramDialog = () => {
this.setState({ openEnableTelegram: true }); this.setState({ openEnableTelegram: true });
}; };
handleClickCloseEnableTelegramDialog = () => { handleClickCloseEnableTelegramDialog = () => {
this.setState({ openEnableTelegram: false }); this.setState({ openEnableTelegram: false });
}; };
@ -534,10 +537,11 @@ class TradeBox extends Component {
</Dialog> </Dialog>
); );
}; };
depositHoursMinutes = () => { depositHoursMinutes = () => {
var hours = parseInt(this.props.data.escrow_duration / 3600); const hours = parseInt(this.props.data.escrow_duration / 3600);
var minutes = parseInt((this.props.data.escrow_duration - hours * 3600) / 60); const minutes = parseInt((this.props.data.escrow_duration - hours * 3600) / 60);
var dict = { deposit_timer_hours: hours, deposit_timer_minutes: minutes }; const dict = { deposit_timer_hours: hours, deposit_timer_minutes: minutes };
return dict; return dict;
}; };
@ -733,7 +737,7 @@ class TradeBox extends Component {
}; };
handleMiningFeeChanged = (e) => { handleMiningFeeChanged = (e) => {
var fee = e.target.value; let fee = e.target.value;
if (fee > 50) { if (fee > 50) {
fee = 50; fee = 50;
} }
@ -796,6 +800,7 @@ class TradeBox extends Component {
}); });
} }
}; };
handleError = (err) => { handleError = (err) => {
console.error(err); console.error(err);
}; };
@ -1389,8 +1394,8 @@ class TradeBox extends Component {
showOpenDisputeButton() { showOpenDisputeButton() {
const { t } = this.props; const { t } = this.props;
let now = Date.now(); const now = Date.now();
var expires_at = new Date(this.props.data.expires_at); const expires_at = new Date(this.props.data.expires_at);
// open dispute button enables 12h before expiry // open dispute button enables 12h before expiry
expires_at.setHours(expires_at.getHours() - 12); expires_at.setHours(expires_at.getHours() - 12);
return ( return (
@ -1457,7 +1462,7 @@ class TradeBox extends Component {
showOrderExpired = () => { showOrderExpired = () => {
const { t } = this.props; const { t } = this.props;
var show_renew = this.props.data.is_maker; const show_renew = this.props.data.is_maker;
return ( return (
<Grid container spacing={1}> <Grid container spacing={1}>
@ -1491,7 +1496,7 @@ class TradeBox extends Component {
showChat = () => { showChat = () => {
const { t } = this.props; const { t } = this.props;
//In Chatroom - No fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton) // In Chatroom - No fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
if (this.props.data.is_buyer & (this.props.data.status == 9)) { if (this.props.data.is_buyer & (this.props.data.status == 9)) {
var showSendButton = true; var showSendButton = true;
var showReveiceButton = false; var showReveiceButton = false;
@ -1503,7 +1508,7 @@ class TradeBox extends Component {
var showDisputeButton = true; var showDisputeButton = true;
} }
//In Chatroom - Fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton) // In Chatroom - Fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
if (this.props.data.is_buyer & (this.props.data.status == 10)) { if (this.props.data.is_buyer & (this.props.data.status == 10)) {
var showSendButton = false; var showSendButton = false;
var showReveiceButton = false; var showReveiceButton = false;
@ -1571,7 +1576,7 @@ class TradeBox extends Component {
showRateSelect() { showRateSelect() {
const { t } = this.props; const { t } = this.props;
var show_renew = this.props.data.is_maker; const show_renew = this.props.data.is_maker;
return ( return (
<Grid container spacing={1}> <Grid container spacing={1}>

View File

@ -39,7 +39,7 @@ interface Item {
name: string; name: string;
} }
type Props = { interface Props {
isMaker: boolean; isMaker: boolean;
makerNick: string; makerNick: string;
takerNick: string; takerNick: string;
@ -48,7 +48,7 @@ type Props = {
takerSummary: Record<string, Item>; takerSummary: Record<string, Item>;
platformSummary: Record<string, Item>; platformSummary: Record<string, Item>;
orderId: number; orderId: number;
}; }
const TradeSummary = ({ const TradeSummary = ({
isMaker, isMaker,
@ -62,7 +62,7 @@ const TradeSummary = ({
}: Props): JSX.Element => { }: Props): JSX.Element => {
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
const [buttonValue, setButtonValue] = useState<number>(isMaker ? 0 : 2); const [buttonValue, setButtonValue] = useState<number>(isMaker ? 0 : 2);
var userSummary = buttonValue == 0 ? makerSummary : takerSummary; const userSummary = buttonValue == 0 ? makerSummary : takerSummary;
const contractTimestamp = new Date(platformSummary.contract_timestamp); const contractTimestamp = new Date(platformSummary.contract_timestamp);
const total_time = platformSummary.contract_total_time; const total_time = platformSummary.contract_total_time;
const hours = parseInt(total_time / 3600); const hours = parseInt(total_time / 3600);

View File

@ -13,7 +13,7 @@ class UnsafeAlert extends Component {
} }
getHost() { getHost() {
var url = const url =
window.location != window.parent.location window.location != window.parent.location
? this.getHost(document.referrer) ? this.getHost(document.referrer)
: document.location.href; : document.location.href;
@ -21,7 +21,7 @@ class UnsafeAlert extends Component {
} }
isSelfhosted() { isSelfhosted() {
var http = new XMLHttpRequest(); const http = new XMLHttpRequest();
http.open('HEAD', `${location.protocol}//${this.getHost()}/selfhosted`, false); http.open('HEAD', `${location.protocol}//${this.getHost()}/selfhosted`, false);
http.send(); http.send();
return http.status != 404; return http.status != 404;

View File

@ -51,7 +51,7 @@ class UserGenPage extends Component {
loadingRobot: false, loadingRobot: false,
}); });
} else { } else {
var newToken = genBase62Token(36); const newToken = genBase62Token(36);
this.setState({ this.setState({
token: newToken, token: newToken,
}); });
@ -109,7 +109,7 @@ class UserGenPage extends Component {
}) })
: this.props.setAppState({ : this.props.setAppState({
nickname: data.nickname, nickname: data.nickname,
token: token, token,
avatarLoaded: false, avatarLoaded: false,
activeOrderId: data.active_order_id ? data.active_order_id : null, activeOrderId: data.active_order_id ? data.active_order_id : null,
lastOrderId: data.last_order_id ? data.last_order_id : null, lastOrderId: data.last_order_id ? data.last_order_id : null,
@ -140,9 +140,9 @@ class UserGenPage extends Component {
} }
handleClickNewRandomToken = () => { handleClickNewRandomToken = () => {
var token = genBase62Token(36); const token = genBase62Token(36);
this.setState({ this.setState({
token: token, token,
tokenHasChanged: true, tokenHasChanged: true,
}); });
this.props.setAppState({ copiedToken: true }); this.props.setAppState({ copiedToken: true });
@ -275,7 +275,7 @@ class UserGenPage extends Component {
<Grid item xs={12} align='center'> <Grid item xs={12} align='center'>
<TextField <TextField
sx={{ maxWidth: 280 * fontSizeFactor }} sx={{ maxWidth: 280 * fontSizeFactor }}
error={this.state.bad_request ? true : false} error={!!this.state.bad_request}
label={t('Store your token safely')} label={t('Store your token safely')}
required={true} required={true}
value={this.state.token} value={this.state.token}

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import DashboardCustomizeIcon from '@mui/icons-material/DashboardCustomize'; import DashboardCustomizeIcon from '@mui/icons-material/DashboardCustomize';
let icons = { const icons = {
airtel: { airtel: {
title: 'airtel', title: 'airtel',
image: image:

View File

@ -7,7 +7,7 @@ export function copyToClipboard(textToCopy) {
return navigator.clipboard.writeText(textToCopy); return navigator.clipboard.writeText(textToCopy);
} else { } else {
// text area method // text area method
let textArea = document.createElement('textarea'); const textArea = document.createElement('textarea');
textArea.value = textToCopy; textArea.value = textToCopy;
// make the textarea out of viewport // make the textarea out of viewport
textArea.style.position = 'fixed'; textArea.style.position = 'fixed';

View File

@ -1,6 +1,6 @@
export const median = (arr: number[]) => { export const median = (arr: number[]) => {
const mid = Math.floor(arr.length / 2), const mid = Math.floor(arr.length / 2);
nums = [...arr].sort((a, b) => a - b); const nums = [...arr].sort((a, b) => a - b);
return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
}; };

View File

@ -16,7 +16,7 @@ export async function genKey(highEntropyToken) {
const keyPair = await generateKey({ const keyPair = await generateKey({
type: 'ecc', // Type of the key, defaults to ECC type: 'ecc', // Type of the key, defaults to ECC
curve: 'curve25519', // ECC curve name, defaults to curve25519 curve: 'curve25519', // ECC curve name, defaults to curve25519
userIDs: [{ name: 'RoboSats ID ' + sha256(sha256(highEntropyToken)) }], //Ideally it would be the avatar nickname, but the nickname is generated only after submission. The second SHA256 can be converted into the Nickname using nick_generator package. userIDs: [{ name: 'RoboSats ID ' + sha256(sha256(highEntropyToken)) }], // Ideally it would be the avatar nickname, but the nickname is generated only after submission. The second SHA256 can be converted into the Nickname using nick_generator package.
passphrase: highEntropyToken, passphrase: highEntropyToken,
format: 'armored', format: 'armored',
date: d.setDate(d.getDate() - 1), // One day of offset. Helps reducing errors due to client's system time being in the future. date: d.setDate(d.getDate() - 1), // One day of offset. Helps reducing errors due to client's system time being in the future.

View File

@ -37,7 +37,7 @@ describe('amountToString', () => {
{ input: ['100.00', true, 50, undefined], output: '50-NaN' }, { input: ['100.00', true, 50, undefined], output: '50-NaN' },
{ input: ['100.00', true, 50, 150], output: '50-150' }, { input: ['100.00', true, 50, 150], output: '50-150' },
].forEach((it) => { ].forEach((it) => {
const params: any[] = it.input || []; const params: any[] = (it.input != null) || [];
const response = amountToString(params[0], params[1], params[2], params[3]); const response = amountToString(params[0], params[1], params[2], params[3]);
expect(response).toBe(it.output); expect(response).toBe(it.output);
}); });

View File

@ -14,5 +14,5 @@ export const getWebln = async (): Promise<WeblnProvider> => {
} }
}); });
return resultPromise; return await resultPromise;
}; };