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 Main from './basic/Main';
|
||||
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 { Button, Grid, ButtonGroup, Dialog, Box } from '@mui/material';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
@ -30,7 +30,7 @@ const MainBox = styled(Box)<MainBoxProps>((props) => ({
|
||||
|
||||
const Main: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const { settings, page, slideDirection, setOpen, windowSize, navbarHeight, hostUrl, origin } =
|
||||
const { settings, page, slideDirection, setOpen, windowSize, navbarHeight, hostUrl } =
|
||||
useContext<UseAppStoreType>(AppContext);
|
||||
const { federation, sortedCoordinators } = useContext<UseFederationStoreType>(FederationContext);
|
||||
const { garage } = useContext<UseGarageStoreType>(GarageContext);
|
||||
|
@ -35,7 +35,7 @@ const MainDialogs = (): JSX.Element => {
|
||||
const [maxAmount, setMaxAmount] = useState<string>('...loading...');
|
||||
|
||||
useEffect(() => {
|
||||
if (focusedCoordinator) {
|
||||
if (focusedCoordinator !== null && focusedCoordinator !== '') {
|
||||
const limits = federation.getCoordinator(focusedCoordinator).limits;
|
||||
if (limits[1000] !== undefined) {
|
||||
setMaxAmount(pn(limits[1000].max_amount * 100000000));
|
||||
@ -108,7 +108,11 @@ const MainDialogs = (): JSX.Element => {
|
||||
onClose={() => {
|
||||
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(() => {
|
||||
// change tab (page) into the current route
|
||||
const pathPage: Page | string = location.pathname.split('/')[1];
|
||||
if (pathPage === 'index.html' || !pathPage) {
|
||||
if (pathPage === 'index.html') {
|
||||
navigate('/robot');
|
||||
setPage('robot');
|
||||
}
|
||||
@ -78,8 +78,7 @@ const NavBar = (): JSX.Element => {
|
||||
};
|
||||
|
||||
const changePage = function (mouseEvent: any, newPage: Page): void {
|
||||
if (newPage === 'none') {
|
||||
} else {
|
||||
if (newPage !== 'none') {
|
||||
handleSlideDirection(page, newPage);
|
||||
setPage(newPage);
|
||||
const param =
|
||||
@ -121,7 +120,7 @@ const NavBar = (): JSX.Element => {
|
||||
setOpen({ ...closeAll, profile: !open.profile });
|
||||
}}
|
||||
icon={
|
||||
garage.getRobot().nickname && garage.getRobot().avatarLoaded ? (
|
||||
garage.getRobot().nickname != null && garage.getRobot().avatarLoaded ? (
|
||||
<RobotAvatar
|
||||
style={{ width: '2.3em', height: '2.3em', position: 'relative', top: '0.2em' }}
|
||||
avatarClass={theme.palette.mode === 'dark' ? 'navBarAvatarDark' : 'navBarAvatar'}
|
||||
|
@ -45,7 +45,7 @@ const OrderPage = (): JSX.Element => {
|
||||
}, [params]);
|
||||
|
||||
const onClickCoordinator = function (): void {
|
||||
if (currentOrder.shortAlias) {
|
||||
if (currentOrder.shortAlias != null) {
|
||||
setFocusedCoordinator(currentOrder.shortAlias);
|
||||
}
|
||||
setOpen((open) => {
|
||||
@ -55,7 +55,7 @@ const OrderPage = (): JSX.Element => {
|
||||
|
||||
const renewOrder = function (): void {
|
||||
const order = currentOrder.order;
|
||||
if (order !== null && focusedCoordinator) {
|
||||
if (order !== null && focusedCoordinator != null) {
|
||||
const body = {
|
||||
type: order.type,
|
||||
currency: order.currency,
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Grid, Typography } from '@mui/material';
|
||||
import { type Robot } from '../../models';
|
||||
import TokenInput from './TokenInput';
|
||||
import Key from '@mui/icons-material/Key';
|
||||
|
||||
|
@ -55,7 +55,7 @@ const RobotProfile = ({
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (garage.getRobot().nickname && garage.getRobot().avatarLoaded) {
|
||||
if (garage.getRobot().nickname != null && garage.getRobot().avatarLoaded) {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [robotUpdatedAt]);
|
||||
@ -81,7 +81,7 @@ const RobotProfile = ({
|
||||
sx={{ width: '100%' }}
|
||||
>
|
||||
<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'>
|
||||
<div
|
||||
style={{
|
||||
|
@ -12,7 +12,6 @@ import {
|
||||
} from '@mui/material';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
import { Robot } from '../../models';
|
||||
import Onboarding from './Onboarding';
|
||||
import Welcome from './Welcome';
|
||||
import RobotProfile from './RobotProfile';
|
||||
@ -77,7 +76,7 @@ const RobotPage = ({ avatarBaseUrl }: RobotPageProps): JSX.Element => {
|
||||
pubKey: key.publicKeyArmored,
|
||||
encPrivKey: key.encryptedPrivateKeyArmored,
|
||||
});
|
||||
federation.fetchRobot(garage, slot);
|
||||
void federation.fetchRobot(garage, slot);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
|
@ -206,9 +206,10 @@ const BookTable = ({
|
||||
headerName: t('Robot'),
|
||||
width: width * fontSize,
|
||||
renderCell: (params: any) => {
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(params.row.coordinatorShortAlias)
|
||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
const { url, basePath } =
|
||||
federation
|
||||
.getCoordinator(params.row.coordinatorShortAlias)
|
||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
||||
|
||||
return (
|
||||
<ListItemButton
|
||||
@ -243,9 +244,10 @@ const BookTable = ({
|
||||
headerName: t('Robot'),
|
||||
width: width * fontSize,
|
||||
renderCell: (params: any) => {
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(params.row.coordinatorShortAlias)
|
||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
const { url, basePath } =
|
||||
federation
|
||||
.getCoordinator(params.row.coordinatorShortAlias)
|
||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
||||
|
||||
return (
|
||||
<div
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
} from '@mui/material';
|
||||
import { AddCircleOutline, RemoveCircleOutline } from '@mui/icons-material';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { type PublicOrder, type Order } from '../../../models';
|
||||
import type PublicOrder from '../../../models';
|
||||
import { matchMedian } from '../../../utils';
|
||||
import currencyDict from '../../../../static/assets/currencies.json';
|
||||
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
|
||||
// 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
|
||||
if (order.coordinatorShortAlias) {
|
||||
if (order.coordinatorShortAlias != null) {
|
||||
const limits = federation.getCoordinator(order.coordinatorShortAlias).limits;
|
||||
order.base_amount =
|
||||
(order.price * limits[currencyCode].price) / limits[order.currency].price;
|
||||
|
@ -12,7 +12,6 @@ import {
|
||||
Tooltip,
|
||||
} from '@mui/material';
|
||||
import Map from '../../Map';
|
||||
import { AppContext, type UseAppStoreType } from '../../../contexts/AppContext';
|
||||
import { PhotoSizeSelectActual } from '@mui/icons-material';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
|
@ -26,7 +26,7 @@ const OrderTooltip: React.FC<OrderTooltipProps> = ({ order }) => {
|
||||
const coordinator = federation.getCoordinator(coordinatorAlias);
|
||||
const baseUrl = coordinator?.[network]?.[origin] ?? '';
|
||||
|
||||
return order?.id && baseUrl !== '' ? (
|
||||
return order?.id != null && baseUrl !== '' ? (
|
||||
<Paper elevation={12} style={{ padding: 10, width: 250 }}>
|
||||
<Grid container justifyContent='space-between'>
|
||||
<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 {
|
||||
|
@ -42,13 +42,13 @@ const F2fMapDialog = ({
|
||||
const [openWarningDialog, setOpenWarningDialog] = useState<boolean>(false);
|
||||
|
||||
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]);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (open && latitude && longitude) {
|
||||
if (open && latitude != null && longitude != null) {
|
||||
setPosition([latitude, longitude]);
|
||||
} else {
|
||||
setPosition(undefined);
|
||||
|
@ -213,7 +213,7 @@ const FederationTable = ({
|
||||
const { columns, width } = filteredColumns();
|
||||
|
||||
const onEnableChange = function (shortAlias: string): void {
|
||||
if (federation.getCoordinator(shortAlias).enabled) {
|
||||
if (federation.getCoordinator(shortAlias).enabled === true) {
|
||||
federation.disableCoordinator(shortAlias);
|
||||
} else {
|
||||
federation.enableCoordinator(shortAlias);
|
||||
|
@ -93,7 +93,7 @@ const MakerForm = ({
|
||||
|
||||
useEffect(() => {
|
||||
setCurrencyCode(currencyDict[fav.currency === 0 ? 1 : fav.currency]);
|
||||
if (focusedCoordinator) {
|
||||
if (focusedCoordinator != null) {
|
||||
const newLimits = federation.getCoordinator(focusedCoordinator).limits;
|
||||
if (Object.keys(newLimits).length !== 0) {
|
||||
updateAmountLimits(newLimits, fav.currency, maker.premium);
|
||||
@ -280,9 +280,10 @@ const MakerForm = ({
|
||||
};
|
||||
|
||||
const handleCreateOrder = function (): void {
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(maker.coordinator)
|
||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
const { url, basePath } =
|
||||
federation
|
||||
.getCoordinator(maker.coordinator)
|
||||
?.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl) ?? {};
|
||||
|
||||
const auth = {
|
||||
tokenSHA256: garage.getRobot().tokenSHA256,
|
||||
@ -292,7 +293,7 @@ const MakerForm = ({
|
||||
},
|
||||
};
|
||||
|
||||
if (!disableRequest && focusedCoordinator) {
|
||||
if (!disableRequest && focusedCoordinator != null) {
|
||||
setSubmittingRequest(true);
|
||||
const body = {
|
||||
type: fav.type === 0 ? 1 : 0,
|
||||
@ -312,9 +313,7 @@ const MakerForm = ({
|
||||
latitude: maker.latitude,
|
||||
longitude: maker.longitude,
|
||||
};
|
||||
const { url } = federation
|
||||
.getCoordinator(focusedCoordinator)
|
||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
|
||||
apiClient
|
||||
.post(url, `${basePath}/api/make/`, body, auth)
|
||||
.then((data: any) => {
|
||||
@ -447,7 +446,7 @@ const MakerForm = ({
|
||||
};
|
||||
|
||||
const amountLabel = useMemo(() => {
|
||||
if (!focusedCoordinator) return;
|
||||
if (!(focusedCoordinator != null)) return;
|
||||
|
||||
const info = federation.getCoordinator(focusedCoordinator)?.info;
|
||||
const defaultRoutingBudget = 0.001;
|
||||
@ -587,7 +586,7 @@ const MakerForm = ({
|
||||
if (pos != null) handleAddLocation(pos);
|
||||
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}>
|
||||
<div style={{ display: Object.keys(limits) === 0 ? '' : 'none' }}>
|
||||
|
Loading…
Reference in New Issue
Block a user