mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Fix lint issues
This commit is contained in:
parent
1fcd12dbab
commit
4eb46f1e16
@ -1,4 +1,4 @@
|
|||||||
import React, { StrictMode, Suspense, useState } from 'react';
|
import React, { StrictMode, Suspense } from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import Main from './basic/Main';
|
import Main from './basic/Main';
|
||||||
import { CssBaseline, ThemeProvider } from '@mui/material';
|
import { CssBaseline, ThemeProvider } from '@mui/material';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useEffect, useState } from 'react';
|
import React, { useContext, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Grid, ButtonGroup, Dialog, Box } from '@mui/material';
|
import { Button, Grid, ButtonGroup, Dialog, Box } from '@mui/material';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
@ -30,7 +30,7 @@ const MainBox = styled(Box)<MainBoxProps>((props) => ({
|
|||||||
|
|
||||||
const Main: React.FC = () => {
|
const Main: React.FC = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { settings, page, slideDirection, setOpen, windowSize, navbarHeight, hostUrl, origin } =
|
const { settings, page, slideDirection, setOpen, windowSize, navbarHeight, hostUrl } =
|
||||||
useContext<UseAppStoreType>(AppContext);
|
useContext<UseAppStoreType>(AppContext);
|
||||||
const { federation, sortedCoordinators } = useContext<UseFederationStoreType>(FederationContext);
|
const { federation, sortedCoordinators } = useContext<UseFederationStoreType>(FederationContext);
|
||||||
const { garage } = useContext<UseGarageStoreType>(GarageContext);
|
const { garage } = useContext<UseGarageStoreType>(GarageContext);
|
||||||
|
@ -35,7 +35,7 @@ const MainDialogs = (): JSX.Element => {
|
|||||||
const [maxAmount, setMaxAmount] = useState<string>('...loading...');
|
const [maxAmount, setMaxAmount] = useState<string>('...loading...');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (focusedCoordinator) {
|
if (focusedCoordinator !== null && focusedCoordinator !== '') {
|
||||||
const limits = federation.getCoordinator(focusedCoordinator).limits;
|
const limits = federation.getCoordinator(focusedCoordinator).limits;
|
||||||
if (limits[1000] !== undefined) {
|
if (limits[1000] !== undefined) {
|
||||||
setMaxAmount(pn(limits[1000].max_amount * 100000000));
|
setMaxAmount(pn(limits[1000].max_amount * 100000000));
|
||||||
@ -108,7 +108,11 @@ const MainDialogs = (): JSX.Element => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
setOpen(closeAll);
|
setOpen(closeAll);
|
||||||
}}
|
}}
|
||||||
coordinator={focusedCoordinator ? federation.getCoordinator(focusedCoordinator) : null}
|
coordinator={
|
||||||
|
focusedCoordinator !== null && focusedCoordinator !== ''
|
||||||
|
? federation.getCoordinator(focusedCoordinator)
|
||||||
|
: null
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -60,7 +60,7 @@ const NavBar = (): JSX.Element => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// change tab (page) into the current route
|
// change tab (page) into the current route
|
||||||
const pathPage: Page | string = location.pathname.split('/')[1];
|
const pathPage: Page | string = location.pathname.split('/')[1];
|
||||||
if (pathPage === 'index.html' || !pathPage) {
|
if (pathPage === 'index.html') {
|
||||||
navigate('/robot');
|
navigate('/robot');
|
||||||
setPage('robot');
|
setPage('robot');
|
||||||
}
|
}
|
||||||
@ -78,8 +78,7 @@ const NavBar = (): JSX.Element => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const changePage = function (mouseEvent: any, newPage: Page): void {
|
const changePage = function (mouseEvent: any, newPage: Page): void {
|
||||||
if (newPage === 'none') {
|
if (newPage !== 'none') {
|
||||||
} else {
|
|
||||||
handleSlideDirection(page, newPage);
|
handleSlideDirection(page, newPage);
|
||||||
setPage(newPage);
|
setPage(newPage);
|
||||||
const param =
|
const param =
|
||||||
@ -121,7 +120,7 @@ const NavBar = (): JSX.Element => {
|
|||||||
setOpen({ ...closeAll, profile: !open.profile });
|
setOpen({ ...closeAll, profile: !open.profile });
|
||||||
}}
|
}}
|
||||||
icon={
|
icon={
|
||||||
garage.getRobot().nickname && garage.getRobot().avatarLoaded ? (
|
garage.getRobot().nickname != null && garage.getRobot().avatarLoaded ? (
|
||||||
<RobotAvatar
|
<RobotAvatar
|
||||||
style={{ width: '2.3em', height: '2.3em', position: 'relative', top: '0.2em' }}
|
style={{ width: '2.3em', height: '2.3em', position: 'relative', top: '0.2em' }}
|
||||||
avatarClass={theme.palette.mode === 'dark' ? 'navBarAvatarDark' : 'navBarAvatar'}
|
avatarClass={theme.palette.mode === 'dark' ? 'navBarAvatarDark' : 'navBarAvatar'}
|
||||||
|
@ -45,7 +45,7 @@ const OrderPage = (): JSX.Element => {
|
|||||||
}, [params]);
|
}, [params]);
|
||||||
|
|
||||||
const onClickCoordinator = function (): void {
|
const onClickCoordinator = function (): void {
|
||||||
if (currentOrder.shortAlias) {
|
if (currentOrder.shortAlias != null) {
|
||||||
setFocusedCoordinator(currentOrder.shortAlias);
|
setFocusedCoordinator(currentOrder.shortAlias);
|
||||||
}
|
}
|
||||||
setOpen((open) => {
|
setOpen((open) => {
|
||||||
@ -55,7 +55,7 @@ const OrderPage = (): JSX.Element => {
|
|||||||
|
|
||||||
const renewOrder = function (): void {
|
const renewOrder = function (): void {
|
||||||
const order = currentOrder.order;
|
const order = currentOrder.order;
|
||||||
if (order !== null && focusedCoordinator) {
|
if (order !== null && focusedCoordinator != null) {
|
||||||
const body = {
|
const body = {
|
||||||
type: order.type,
|
type: order.type,
|
||||||
currency: order.currency,
|
currency: order.currency,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Grid, Typography } from '@mui/material';
|
import { Button, Grid, Typography } from '@mui/material';
|
||||||
import { type Robot } from '../../models';
|
|
||||||
import TokenInput from './TokenInput';
|
import TokenInput from './TokenInput';
|
||||||
import Key from '@mui/icons-material/Key';
|
import Key from '@mui/icons-material/Key';
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ const RobotProfile = ({
|
|||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (garage.getRobot().nickname && garage.getRobot().avatarLoaded) {
|
if (garage.getRobot().nickname != null && garage.getRobot().avatarLoaded) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [robotUpdatedAt]);
|
}, [robotUpdatedAt]);
|
||||||
@ -81,7 +81,7 @@ const RobotProfile = ({
|
|||||||
sx={{ width: '100%' }}
|
sx={{ width: '100%' }}
|
||||||
>
|
>
|
||||||
<Grid item sx={{ height: '2.3em', position: 'relative' }}>
|
<Grid item sx={{ height: '2.3em', position: 'relative' }}>
|
||||||
{garage.getRobot().avatarLoaded && garage.getRobot().nickname ? (
|
{garage.getRobot().avatarLoaded && garage.getRobot().nickname != null ? (
|
||||||
<Typography align='center' component='h5' variant='h5'>
|
<Typography align='center' component='h5' variant='h5'>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -12,7 +12,6 @@ import {
|
|||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { Robot } from '../../models';
|
|
||||||
import Onboarding from './Onboarding';
|
import Onboarding from './Onboarding';
|
||||||
import Welcome from './Welcome';
|
import Welcome from './Welcome';
|
||||||
import RobotProfile from './RobotProfile';
|
import RobotProfile from './RobotProfile';
|
||||||
@ -77,7 +76,7 @@ const RobotPage = ({ avatarBaseUrl }: RobotPageProps): JSX.Element => {
|
|||||||
pubKey: key.publicKeyArmored,
|
pubKey: key.publicKeyArmored,
|
||||||
encPrivKey: key.encryptedPrivateKeyArmored,
|
encPrivKey: key.encryptedPrivateKeyArmored,
|
||||||
});
|
});
|
||||||
federation.fetchRobot(garage, slot);
|
void federation.fetchRobot(garage, slot);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
|
@ -206,9 +206,10 @@ const BookTable = ({
|
|||||||
headerName: t('Robot'),
|
headerName: t('Robot'),
|
||||||
width: width * fontSize,
|
width: width * fontSize,
|
||||||
renderCell: (params: any) => {
|
renderCell: (params: any) => {
|
||||||
const { url, basePath } = federation
|
const { url, basePath } =
|
||||||
.getCoordinator(params.row.coordinatorShortAlias)
|
federation
|
||||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
.getCoordinator(params.row.coordinatorShortAlias)
|
||||||
|
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
@ -243,9 +244,10 @@ const BookTable = ({
|
|||||||
headerName: t('Robot'),
|
headerName: t('Robot'),
|
||||||
width: width * fontSize,
|
width: width * fontSize,
|
||||||
renderCell: (params: any) => {
|
renderCell: (params: any) => {
|
||||||
const { url, basePath } = federation
|
const { url, basePath } =
|
||||||
.getCoordinator(params.row.coordinatorShortAlias)
|
federation
|
||||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
.getCoordinator(params.row.coordinatorShortAlias)
|
||||||
|
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { AddCircleOutline, RemoveCircleOutline } from '@mui/icons-material';
|
import { AddCircleOutline, RemoveCircleOutline } from '@mui/icons-material';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { type PublicOrder, type Order } from '../../../models';
|
import type PublicOrder from '../../../models';
|
||||||
import { matchMedian } from '../../../utils';
|
import { matchMedian } from '../../../utils';
|
||||||
import currencyDict from '../../../../static/assets/currencies.json';
|
import currencyDict from '../../../../static/assets/currencies.json';
|
||||||
import getNivoScheme from '../NivoScheme';
|
import getNivoScheme from '../NivoScheme';
|
||||||
@ -72,7 +72,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
|
|||||||
// We need to transform all currencies to the same base (ex. USD), we don't have the exchange rate
|
// We need to transform all currencies to the same base (ex. USD), we don't have the exchange rate
|
||||||
// for EUR -> USD, but we know the rate of both to BTC, so we get advantage of it and apply a
|
// for EUR -> USD, but we know the rate of both to BTC, so we get advantage of it and apply a
|
||||||
// simple rule of three
|
// simple rule of three
|
||||||
if (order.coordinatorShortAlias) {
|
if (order.coordinatorShortAlias != null) {
|
||||||
const limits = federation.getCoordinator(order.coordinatorShortAlias).limits;
|
const limits = federation.getCoordinator(order.coordinatorShortAlias).limits;
|
||||||
order.base_amount =
|
order.base_amount =
|
||||||
(order.price * limits[currencyCode].price) / limits[order.currency].price;
|
(order.price * limits[currencyCode].price) / limits[order.currency].price;
|
||||||
|
@ -12,7 +12,6 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import Map from '../../Map';
|
import Map from '../../Map';
|
||||||
import { AppContext, type UseAppStoreType } from '../../../contexts/AppContext';
|
|
||||||
import { PhotoSizeSelectActual } from '@mui/icons-material';
|
import { PhotoSizeSelectActual } from '@mui/icons-material';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import {
|
||||||
|
@ -26,7 +26,7 @@ const OrderTooltip: React.FC<OrderTooltipProps> = ({ order }) => {
|
|||||||
const coordinator = federation.getCoordinator(coordinatorAlias);
|
const coordinator = federation.getCoordinator(coordinatorAlias);
|
||||||
const baseUrl = coordinator?.[network]?.[origin] ?? '';
|
const baseUrl = coordinator?.[network]?.[origin] ?? '';
|
||||||
|
|
||||||
return order?.id && baseUrl !== '' ? (
|
return order?.id != null && baseUrl !== '' ? (
|
||||||
<Paper elevation={12} style={{ padding: 10, width: 250 }}>
|
<Paper elevation={12} style={{ padding: 10, width: 250 }}>
|
||||||
<Grid container justifyContent='space-between'>
|
<Grid container justifyContent='space-between'>
|
||||||
<Grid item xs={3}>
|
<Grid item xs={3}>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useEffect, useState } from 'react';
|
import React, { useContext, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -42,13 +42,13 @@ const F2fMapDialog = ({
|
|||||||
const [openWarningDialog, setOpenWarningDialog] = useState<boolean>(false);
|
const [openWarningDialog, setOpenWarningDialog] = useState<boolean>(false);
|
||||||
|
|
||||||
const onSave: () => void = () => {
|
const onSave: () => void = () => {
|
||||||
if (position?.[0] && position?.[1]) {
|
if (position?.[0] != null && position?.[1] != null) {
|
||||||
onClose([position[0] + Math.random() * 0.1 - 0.05, position[1] + Math.random() * 0.1 - 0.05]);
|
onClose([position[0] + Math.random() * 0.1 - 0.05, position[1] + Math.random() * 0.1 - 0.05]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open && latitude && longitude) {
|
if (open && latitude != null && longitude != null) {
|
||||||
setPosition([latitude, longitude]);
|
setPosition([latitude, longitude]);
|
||||||
} else {
|
} else {
|
||||||
setPosition(undefined);
|
setPosition(undefined);
|
||||||
|
@ -213,7 +213,7 @@ const FederationTable = ({
|
|||||||
const { columns, width } = filteredColumns();
|
const { columns, width } = filteredColumns();
|
||||||
|
|
||||||
const onEnableChange = function (shortAlias: string): void {
|
const onEnableChange = function (shortAlias: string): void {
|
||||||
if (federation.getCoordinator(shortAlias).enabled) {
|
if (federation.getCoordinator(shortAlias).enabled === true) {
|
||||||
federation.disableCoordinator(shortAlias);
|
federation.disableCoordinator(shortAlias);
|
||||||
} else {
|
} else {
|
||||||
federation.enableCoordinator(shortAlias);
|
federation.enableCoordinator(shortAlias);
|
||||||
|
@ -93,7 +93,7 @@ const MakerForm = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrencyCode(currencyDict[fav.currency === 0 ? 1 : fav.currency]);
|
setCurrencyCode(currencyDict[fav.currency === 0 ? 1 : fav.currency]);
|
||||||
if (focusedCoordinator) {
|
if (focusedCoordinator != null) {
|
||||||
const newLimits = federation.getCoordinator(focusedCoordinator).limits;
|
const newLimits = federation.getCoordinator(focusedCoordinator).limits;
|
||||||
if (Object.keys(newLimits).length !== 0) {
|
if (Object.keys(newLimits).length !== 0) {
|
||||||
updateAmountLimits(newLimits, fav.currency, maker.premium);
|
updateAmountLimits(newLimits, fav.currency, maker.premium);
|
||||||
@ -280,9 +280,10 @@ const MakerForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateOrder = function (): void {
|
const handleCreateOrder = function (): void {
|
||||||
const { url, basePath } = federation
|
const { url, basePath } =
|
||||||
.getCoordinator(maker.coordinator)
|
federation
|
||||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
.getCoordinator(maker.coordinator)
|
||||||
|
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
||||||
|
|
||||||
const auth = {
|
const auth = {
|
||||||
tokenSHA256: garage.getRobot().tokenSHA256,
|
tokenSHA256: garage.getRobot().tokenSHA256,
|
||||||
@ -292,7 +293,7 @@ const MakerForm = ({
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!disableRequest && focusedCoordinator) {
|
if (!disableRequest && focusedCoordinator != null) {
|
||||||
setSubmittingRequest(true);
|
setSubmittingRequest(true);
|
||||||
const body = {
|
const body = {
|
||||||
type: fav.type === 0 ? 1 : 0,
|
type: fav.type === 0 ? 1 : 0,
|
||||||
@ -312,9 +313,7 @@ const MakerForm = ({
|
|||||||
latitude: maker.latitude,
|
latitude: maker.latitude,
|
||||||
longitude: maker.longitude,
|
longitude: maker.longitude,
|
||||||
};
|
};
|
||||||
const { url } = federation
|
|
||||||
.getCoordinator(focusedCoordinator)
|
|
||||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
|
||||||
apiClient
|
apiClient
|
||||||
.post(url, `${basePath}/api/make/`, body, auth)
|
.post(url, `${basePath}/api/make/`, body, auth)
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
@ -447,7 +446,7 @@ const MakerForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const amountLabel = useMemo(() => {
|
const amountLabel = useMemo(() => {
|
||||||
if (!focusedCoordinator) return;
|
if (!(focusedCoordinator != null)) return;
|
||||||
|
|
||||||
const info = federation.getCoordinator(focusedCoordinator)?.info;
|
const info = federation.getCoordinator(focusedCoordinator)?.info;
|
||||||
const defaultRoutingBudget = 0.001;
|
const defaultRoutingBudget = 0.001;
|
||||||
@ -587,7 +586,7 @@ const MakerForm = ({
|
|||||||
if (pos != null) handleAddLocation(pos);
|
if (pos != null) handleAddLocation(pos);
|
||||||
setOpenWorldmap(false);
|
setOpenWorldmap(false);
|
||||||
}}
|
}}
|
||||||
zoom={maker.latitude && maker.longitude ? 6 : undefined}
|
zoom={maker.latitude != null && maker.longitude != null ? 6 : undefined}
|
||||||
/>
|
/>
|
||||||
<Collapse in={Object.keys(limits).lenght === 0}>
|
<Collapse in={Object.keys(limits).lenght === 0}>
|
||||||
<div style={{ display: Object.keys(limits) === 0 ? '' : 'none' }}>
|
<div style={{ display: Object.keys(limits) === 0 ? '' : 'none' }}>
|
||||||
|
Loading…
Reference in New Issue
Block a user