2022-10-20 18:06:16 +00:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2022-11-21 12:56:29 +00:00
|
|
|
import { HashRouter, BrowserRouter, Switch, Route } from 'react-router-dom';
|
2022-11-07 16:45:05 +00:00
|
|
|
import { useTheme, Box, Slide, Typography } from '@mui/material';
|
2022-10-20 18:06:16 +00:00
|
|
|
|
|
|
|
import UserGenPage from './UserGenPage';
|
|
|
|
import MakerPage from './MakerPage';
|
|
|
|
import BookPage from './BookPage';
|
|
|
|
import OrderPage from './OrderPage';
|
2022-10-30 19:13:01 +00:00
|
|
|
import SettingsPage from './SettingsPage';
|
|
|
|
import NavBar, { Page } from './NavBar';
|
|
|
|
import MainDialogs, { OpenDialogs } from './MainDialogs';
|
2022-10-20 18:06:16 +00:00
|
|
|
|
2022-10-30 19:13:01 +00:00
|
|
|
import RobotAvatar from '../components/RobotAvatar';
|
2022-10-20 18:06:16 +00:00
|
|
|
import {
|
|
|
|
Book,
|
|
|
|
LimitList,
|
|
|
|
Maker,
|
|
|
|
Robot,
|
|
|
|
Info,
|
|
|
|
Settings,
|
|
|
|
Favorites,
|
|
|
|
defaultMaker,
|
|
|
|
defaultInfo,
|
2022-10-30 19:13:01 +00:00
|
|
|
Coordinator,
|
2022-11-21 12:56:29 +00:00
|
|
|
Order,
|
2022-10-20 18:06:16 +00:00
|
|
|
} from '../models';
|
|
|
|
|
2022-10-30 19:13:01 +00:00
|
|
|
import { apiClient } from '../services/api';
|
2022-11-07 16:45:05 +00:00
|
|
|
import { checkVer, getHost } from '../utils';
|
2022-10-30 19:13:01 +00:00
|
|
|
import { sha256 } from 'js-sha256';
|
|
|
|
|
|
|
|
import defaultCoordinators from '../../static/federation.json';
|
2022-11-07 16:45:05 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2022-11-21 12:56:29 +00:00
|
|
|
import Notifications from '../components/Notifications';
|
2022-10-22 14:32:33 +00:00
|
|
|
|
2022-10-20 18:06:16 +00:00
|
|
|
const getWindowSize = function (fontSize: number) {
|
|
|
|
// returns window size in EM units
|
|
|
|
return {
|
|
|
|
width: window.innerWidth / fontSize,
|
|
|
|
height: window.innerHeight / fontSize,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-21 12:56:29 +00:00
|
|
|
// Refresh delays (ms) according to Order status
|
|
|
|
const statusToDelay = [
|
|
|
|
3000, // 'Waiting for maker bond'
|
|
|
|
35000, // 'Public'
|
|
|
|
180000, // 'Paused'
|
|
|
|
3000, // 'Waiting for taker bond'
|
|
|
|
999999, // 'Cancelled'
|
|
|
|
999999, // 'Expired'
|
|
|
|
8000, // 'Waiting for trade collateral and buyer invoice'
|
|
|
|
8000, // 'Waiting only for seller trade collateral'
|
|
|
|
8000, // 'Waiting only for buyer invoice'
|
|
|
|
10000, // 'Sending fiat - In chatroom'
|
|
|
|
10000, // 'Fiat sent - In chatroom'
|
|
|
|
100000, // 'In dispute'
|
|
|
|
999999, // 'Collaboratively cancelled'
|
|
|
|
10000, // 'Sending satoshis to buyer'
|
|
|
|
999999, // 'Sucessful trade'
|
|
|
|
30000, // 'Failed lightning network routing'
|
|
|
|
300000, // 'Wait for dispute resolution'
|
|
|
|
300000, // 'Maker lost dispute'
|
|
|
|
300000, // 'Taker lost dispute'
|
|
|
|
];
|
|
|
|
|
2022-10-30 19:13:01 +00:00
|
|
|
interface SlideDirection {
|
|
|
|
in: 'left' | 'right' | undefined;
|
|
|
|
out: 'left' | 'right' | undefined;
|
|
|
|
}
|
|
|
|
|
2022-10-22 14:32:33 +00:00
|
|
|
interface MainProps {
|
|
|
|
settings: Settings;
|
|
|
|
setSettings: (state: Settings) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
2022-11-07 16:45:05 +00:00
|
|
|
const { t } = useTranslation();
|
2022-11-21 12:56:29 +00:00
|
|
|
const theme = useTheme();
|
2022-11-07 16:45:05 +00:00
|
|
|
|
2022-10-20 18:06:16 +00:00
|
|
|
// All app data structured
|
|
|
|
const [book, setBook] = useState<Book>({ orders: [], loading: true });
|
|
|
|
const [limits, setLimits] = useState<{ list: LimitList; loading: boolean }>({
|
|
|
|
list: [],
|
|
|
|
loading: true,
|
|
|
|
});
|
2022-11-06 16:20:54 +00:00
|
|
|
const [robot, setRobot] = useState<Robot>(new Robot());
|
2022-10-20 18:06:16 +00:00
|
|
|
const [maker, setMaker] = useState<Maker>(defaultMaker);
|
|
|
|
const [info, setInfo] = useState<Info>(defaultInfo);
|
2022-10-30 19:13:01 +00:00
|
|
|
const [coordinators, setCoordinators] = useState<Coordinator[]>(defaultCoordinators);
|
2022-11-07 16:45:05 +00:00
|
|
|
const [baseUrl, setBaseUrl] = useState<string>('');
|
2023-02-10 13:28:26 +00:00
|
|
|
const [fav, setFav] = useState<Favorites>({ type: null, mode: 'fiat', currency: 0 });
|
2022-10-20 18:06:16 +00:00
|
|
|
|
2022-11-21 12:56:29 +00:00
|
|
|
const [delay, setDelay] = useState<number>(60000);
|
|
|
|
const [timer, setTimer] = useState<NodeJS.Timer | undefined>(setInterval(() => null, delay));
|
|
|
|
const [order, setOrder] = useState<Order | undefined>(undefined);
|
|
|
|
const [badOrder, setBadOrder] = useState<string | undefined>(undefined);
|
2022-10-30 19:13:01 +00:00
|
|
|
|
2022-10-31 16:20:20 +00:00
|
|
|
const Router = window.NativeRobosats === undefined ? BrowserRouter : HashRouter;
|
|
|
|
const basename = window.NativeRobosats === undefined ? '' : window.location.pathname;
|
|
|
|
const entryPage: Page | '' =
|
|
|
|
window.NativeRobosats === undefined ? window.location.pathname.split('/')[1] : '';
|
2022-10-31 18:03:34 +00:00
|
|
|
const [page, setPage] = useState<Page>(entryPage == '' ? 'robot' : entryPage);
|
2022-10-30 19:13:01 +00:00
|
|
|
const [slideDirection, setSlideDirection] = useState<SlideDirection>({
|
|
|
|
in: undefined,
|
|
|
|
out: undefined,
|
|
|
|
});
|
2022-11-21 12:56:29 +00:00
|
|
|
|
|
|
|
const [currentOrder, setCurrentOrder] = useState<number | undefined>(undefined);
|
2022-10-30 19:13:01 +00:00
|
|
|
|
|
|
|
const navbarHeight = 2.5;
|
|
|
|
const closeAll = {
|
|
|
|
more: false,
|
|
|
|
learn: false,
|
|
|
|
community: false,
|
|
|
|
info: false,
|
|
|
|
coordinator: false,
|
|
|
|
stats: false,
|
|
|
|
update: false,
|
|
|
|
profile: false,
|
|
|
|
};
|
|
|
|
const [open, setOpen] = useState<OpenDialogs>(closeAll);
|
|
|
|
|
2022-10-20 18:06:16 +00:00
|
|
|
const [windowSize, setWindowSize] = useState<{ width: number; height: number }>(
|
|
|
|
getWindowSize(theme.typography.fontSize),
|
|
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (typeof window !== undefined) {
|
|
|
|
window.addEventListener('resize', onResize);
|
|
|
|
}
|
2022-11-21 12:56:29 +00:00
|
|
|
|
|
|
|
if (baseUrl != '') {
|
|
|
|
fetchBook();
|
|
|
|
fetchLimits();
|
|
|
|
}
|
2022-10-20 18:06:16 +00:00
|
|
|
return () => {
|
|
|
|
if (typeof window !== undefined) {
|
|
|
|
window.removeEventListener('resize', onResize);
|
|
|
|
}
|
|
|
|
};
|
2022-11-07 16:45:05 +00:00
|
|
|
}, [baseUrl]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
let host = '';
|
|
|
|
if (window.NativeRobosats === undefined) {
|
|
|
|
host = getHost();
|
|
|
|
} else {
|
|
|
|
host =
|
|
|
|
settings.network === 'mainnet'
|
|
|
|
? coordinators[0].mainnetOnion
|
|
|
|
: coordinators[0].testnetOnion;
|
|
|
|
}
|
|
|
|
setBaseUrl(`http://${host}`);
|
|
|
|
}, [settings.network]);
|
2022-10-20 18:06:16 +00:00
|
|
|
|
2022-10-30 19:13:01 +00:00
|
|
|
useEffect(() => {
|
|
|
|
setWindowSize(getWindowSize(theme.typography.fontSize));
|
|
|
|
}, [theme.typography.fontSize]);
|
|
|
|
|
2022-10-20 18:06:16 +00:00
|
|
|
const onResize = function () {
|
|
|
|
setWindowSize(getWindowSize(theme.typography.fontSize));
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchBook = function () {
|
|
|
|
setBook({ ...book, loading: true });
|
2022-11-07 16:45:05 +00:00
|
|
|
apiClient.get(baseUrl, '/api/book/').then((data: any) =>
|
2022-10-20 18:06:16 +00:00
|
|
|
setBook({
|
|
|
|
loading: false,
|
|
|
|
orders: data.not_found ? [] : data,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchLimits = async () => {
|
|
|
|
setLimits({ ...limits, loading: true });
|
2022-11-07 16:45:05 +00:00
|
|
|
const data = apiClient.get(baseUrl, '/api/limits/').then((data) => {
|
2022-10-20 18:06:16 +00:00
|
|
|
setLimits({ list: data ?? [], loading: false });
|
|
|
|
return data;
|
|
|
|
});
|
|
|
|
return await data;
|
|
|
|
};
|
|
|
|
|
2022-11-26 11:22:45 +00:00
|
|
|
const fetchInfo = function () {
|
2022-10-31 18:03:34 +00:00
|
|
|
setInfo({ ...info, loading: true });
|
2022-11-07 16:45:05 +00:00
|
|
|
apiClient.get(baseUrl, '/api/info/').then((data: Info) => {
|
2022-10-20 18:06:16 +00:00
|
|
|
const versionInfo: any = checkVer(data.version.major, data.version.minor, data.version.patch);
|
|
|
|
setInfo({
|
|
|
|
...data,
|
|
|
|
openUpdateClient: versionInfo.updateAvailable,
|
|
|
|
coordinatorVersion: versionInfo.coordinatorVersion,
|
|
|
|
clientVersion: versionInfo.clientVersion,
|
2022-10-31 18:03:34 +00:00
|
|
|
loading: false,
|
2022-10-30 19:13:01 +00:00
|
|
|
});
|
2022-10-20 18:06:16 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-10-30 19:13:01 +00:00
|
|
|
useEffect(() => {
|
2022-11-21 12:56:29 +00:00
|
|
|
if (open.stats || open.coordinator || info.coordinatorVersion == 'v?.?.?') {
|
2022-11-26 11:22:45 +00:00
|
|
|
fetchInfo();
|
2022-10-31 18:03:34 +00:00
|
|
|
}
|
2022-10-30 19:13:01 +00:00
|
|
|
}, [open.stats, open.coordinator]);
|
|
|
|
|
2022-11-26 11:22:45 +00:00
|
|
|
useEffect(() => {
|
|
|
|
// Sets Setting network from coordinator API param if accessing via web
|
2022-11-27 20:34:37 +00:00
|
|
|
if (settings.network == undefined && info.network) {
|
|
|
|
setSettings((settings: Settings) => {
|
|
|
|
return { ...settings, network: info.network };
|
|
|
|
});
|
2022-11-26 11:22:45 +00:00
|
|
|
}
|
|
|
|
}, [info]);
|
|
|
|
|
2022-10-31 18:03:34 +00:00
|
|
|
const fetchRobot = function ({ keys = false }) {
|
2022-10-30 19:13:01 +00:00
|
|
|
const requestBody = {
|
|
|
|
token_sha256: sha256(robot.token),
|
|
|
|
};
|
2022-10-31 18:03:34 +00:00
|
|
|
if (keys) {
|
|
|
|
requestBody.pub_key = robot.pubKey;
|
|
|
|
requestBody.enc_priv_key = robot.encPrivKey;
|
|
|
|
}
|
2022-10-30 19:13:01 +00:00
|
|
|
|
2022-10-31 18:03:34 +00:00
|
|
|
setRobot({ ...robot, loading: true });
|
2022-11-07 16:45:05 +00:00
|
|
|
apiClient.post(baseUrl, '/api/user/', requestBody).then((data: any) => {
|
2022-11-07 10:13:02 +00:00
|
|
|
setCurrentOrder(
|
2022-10-30 19:13:01 +00:00
|
|
|
data.active_order_id
|
|
|
|
? data.active_order_id
|
|
|
|
: data.last_order_id
|
|
|
|
? data.last_order_id
|
2022-10-31 16:20:20 +00:00
|
|
|
: null,
|
2022-10-30 19:13:01 +00:00
|
|
|
);
|
|
|
|
setRobot({
|
|
|
|
...robot,
|
|
|
|
nickname: data.nickname,
|
|
|
|
token: robot.token,
|
|
|
|
loading: false,
|
2022-11-21 12:56:29 +00:00
|
|
|
avatarLoaded: robot.nickname === data.nickname,
|
2022-10-30 19:13:01 +00:00
|
|
|
activeOrderId: data.active_order_id ? data.active_order_id : null,
|
|
|
|
lastOrderId: data.last_order_id ? data.last_order_id : null,
|
|
|
|
referralCode: data.referral_code,
|
|
|
|
earnedRewards: data.earned_rewards ?? 0,
|
|
|
|
stealthInvoices: data.wants_stealth,
|
|
|
|
tgEnabled: data.tg_enabled,
|
|
|
|
tgBotName: data.tg_bot_name,
|
|
|
|
tgToken: data.tg_token,
|
|
|
|
bitsEntropy: data.token_bits_entropy,
|
|
|
|
shannonEntropy: data.token_shannon_entropy,
|
2022-10-31 18:03:34 +00:00
|
|
|
pubKey: data.public_key,
|
|
|
|
encPrivKey: data.encrypted_private_key,
|
2022-10-30 19:13:01 +00:00
|
|
|
copiedToken: data.found ? true : robot.copiedToken,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
2022-11-21 12:56:29 +00:00
|
|
|
if (baseUrl != '' && page != 'robot') {
|
2022-11-11 10:08:51 +00:00
|
|
|
if (open.profile || (robot.token && robot.nickname === null)) {
|
|
|
|
fetchRobot({ keys: false }); // fetch existing robot
|
|
|
|
} else if (robot.token && robot.encPrivKey && robot.pubKey) {
|
|
|
|
fetchRobot({ keys: true }); // create new robot with existing token and keys (on network and coordinator change)
|
|
|
|
}
|
2022-10-30 19:13:01 +00:00
|
|
|
}
|
2022-11-11 10:08:51 +00:00
|
|
|
}, [open.profile, baseUrl]);
|
2022-10-30 19:13:01 +00:00
|
|
|
|
2022-11-21 12:56:29 +00:00
|
|
|
// Fetch current order at load and in a loop
|
|
|
|
useEffect(() => {
|
|
|
|
if (currentOrder != undefined && (page == 'order' || (order == badOrder) == undefined)) {
|
|
|
|
fetchOrder();
|
|
|
|
}
|
|
|
|
}, [currentOrder, page]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
clearInterval(timer);
|
|
|
|
setTimer(setInterval(fetchOrder, delay));
|
|
|
|
return () => clearInterval(timer);
|
|
|
|
}, [delay, currentOrder, page, badOrder]);
|
|
|
|
|
|
|
|
const orderReceived = function (data: any) {
|
|
|
|
if (data.bad_request != undefined) {
|
|
|
|
setBadOrder(data.bad_request);
|
|
|
|
setDelay(99999999);
|
|
|
|
setOrder(undefined);
|
|
|
|
} else {
|
|
|
|
setDelay(
|
|
|
|
data.status >= 0 && data.status <= 18
|
|
|
|
? page == 'order'
|
|
|
|
? statusToDelay[data.status]
|
|
|
|
: statusToDelay[data.status] * 5
|
|
|
|
: 99999999,
|
|
|
|
);
|
|
|
|
setOrder(data);
|
|
|
|
setBadOrder(undefined);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchOrder = function () {
|
|
|
|
if (currentOrder != undefined) {
|
|
|
|
apiClient.get(baseUrl, '/api/order/?order_id=' + currentOrder).then(orderReceived);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const clearOrder = function () {
|
|
|
|
setOrder(undefined);
|
|
|
|
setBadOrder(undefined);
|
|
|
|
};
|
|
|
|
|
2022-10-20 18:06:16 +00:00
|
|
|
return (
|
|
|
|
<Router basename={basename}>
|
2022-10-30 19:13:01 +00:00
|
|
|
{/* load robot avatar image, set avatarLoaded: true */}
|
|
|
|
<RobotAvatar
|
|
|
|
style={{ display: 'none' }}
|
|
|
|
nickname={robot.nickname}
|
2022-11-07 16:45:05 +00:00
|
|
|
baseUrl={baseUrl}
|
2022-10-30 19:13:01 +00:00
|
|
|
onLoad={() => setRobot({ ...robot, avatarLoaded: true })}
|
|
|
|
/>
|
2022-11-21 12:56:29 +00:00
|
|
|
<Notifications
|
|
|
|
order={order}
|
|
|
|
page={page}
|
|
|
|
openProfile={() => setOpen({ ...closeAll, profile: true })}
|
|
|
|
rewards={robot.earnedRewards}
|
|
|
|
setPage={setPage}
|
|
|
|
windowWidth={windowSize.width}
|
|
|
|
/>
|
2022-11-07 16:45:05 +00:00
|
|
|
{settings.network === 'testnet' ? (
|
|
|
|
<div style={{ height: 0 }}>
|
|
|
|
<Typography color='secondary' align='center'>
|
|
|
|
<i>{t('Using Testnet Bitcoin')}</i>
|
|
|
|
</Typography>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
)}
|
|
|
|
|
2022-10-30 19:13:01 +00:00
|
|
|
<Box
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: '50%',
|
|
|
|
left: '50%',
|
|
|
|
transform: `translate(-50%, -50%) translate(0, -${navbarHeight / 2}em`,
|
|
|
|
}}
|
|
|
|
>
|
2022-10-20 18:06:16 +00:00
|
|
|
<Switch>
|
|
|
|
<Route
|
2022-10-31 18:03:34 +00:00
|
|
|
path={['/robot/:refCode?', '/']}
|
|
|
|
exact
|
2022-10-20 18:06:16 +00:00
|
|
|
render={(props: any) => (
|
2022-10-30 19:13:01 +00:00
|
|
|
<Slide
|
|
|
|
direction={page === 'robot' ? slideDirection.in : slideDirection.out}
|
|
|
|
in={page === 'robot'}
|
|
|
|
appear={slideDirection.in != undefined}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<UserGenPage
|
|
|
|
setPage={setPage}
|
2022-11-07 10:13:02 +00:00
|
|
|
setCurrentOrder={setCurrentOrder}
|
2022-10-30 19:13:01 +00:00
|
|
|
match={props.match}
|
|
|
|
theme={theme}
|
|
|
|
robot={robot}
|
|
|
|
setRobot={setRobot}
|
2022-11-07 16:45:05 +00:00
|
|
|
baseUrl={baseUrl}
|
2022-10-30 19:13:01 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Slide>
|
2022-10-20 18:06:16 +00:00
|
|
|
)}
|
|
|
|
/>
|
2022-10-30 19:13:01 +00:00
|
|
|
|
2022-10-31 18:03:34 +00:00
|
|
|
<Route path={'/offers'}>
|
2022-10-30 19:13:01 +00:00
|
|
|
<Slide
|
|
|
|
direction={page === 'offers' ? slideDirection.in : slideDirection.out}
|
|
|
|
in={page === 'offers'}
|
|
|
|
appear={slideDirection.in != undefined}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<BookPage
|
|
|
|
book={book}
|
|
|
|
fetchBook={fetchBook}
|
2022-11-21 12:56:29 +00:00
|
|
|
onViewOrder={() => {
|
|
|
|
setOrder(undefined);
|
|
|
|
setDelay(10000);
|
|
|
|
}}
|
2022-10-30 19:13:01 +00:00
|
|
|
limits={limits}
|
|
|
|
fetchLimits={fetchLimits}
|
|
|
|
fav={fav}
|
|
|
|
setFav={setFav}
|
|
|
|
maker={maker}
|
|
|
|
setMaker={setMaker}
|
2022-11-21 12:56:29 +00:00
|
|
|
clearOrder={clearOrder}
|
2022-10-30 19:13:01 +00:00
|
|
|
lastDayPremium={info.last_day_nonkyc_btc_premium}
|
|
|
|
windowSize={windowSize}
|
|
|
|
hasRobot={robot.avatarLoaded}
|
|
|
|
setPage={setPage}
|
2022-11-07 10:13:02 +00:00
|
|
|
setCurrentOrder={setCurrentOrder}
|
2022-11-07 16:45:05 +00:00
|
|
|
baseUrl={baseUrl}
|
2022-10-30 19:13:01 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Slide>
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
<Route path='/create'>
|
|
|
|
<Slide
|
|
|
|
direction={page === 'create' ? slideDirection.in : slideDirection.out}
|
|
|
|
in={page === 'create'}
|
|
|
|
appear={slideDirection.in != undefined}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<MakerPage
|
|
|
|
book={book}
|
|
|
|
limits={limits}
|
|
|
|
fetchLimits={fetchLimits}
|
|
|
|
maker={maker}
|
|
|
|
setMaker={setMaker}
|
2022-11-21 12:56:29 +00:00
|
|
|
clearOrder={clearOrder}
|
2022-10-30 19:13:01 +00:00
|
|
|
setPage={setPage}
|
2022-11-07 10:13:02 +00:00
|
|
|
setCurrentOrder={setCurrentOrder}
|
2022-10-30 19:13:01 +00:00
|
|
|
fav={fav}
|
|
|
|
setFav={setFav}
|
|
|
|
windowSize={{ ...windowSize, height: windowSize.height - navbarHeight }}
|
|
|
|
hasRobot={robot.avatarLoaded}
|
2022-11-07 16:45:05 +00:00
|
|
|
baseUrl={baseUrl}
|
2022-10-30 19:13:01 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Slide>
|
|
|
|
</Route>
|
|
|
|
|
2022-10-20 18:06:16 +00:00
|
|
|
<Route
|
2022-10-30 19:13:01 +00:00
|
|
|
path='/order/:orderId'
|
2022-10-20 18:06:16 +00:00
|
|
|
render={(props: any) => (
|
2022-10-30 19:13:01 +00:00
|
|
|
<Slide
|
|
|
|
direction={page === 'order' ? slideDirection.in : slideDirection.out}
|
|
|
|
in={page === 'order'}
|
|
|
|
appear={slideDirection.in != undefined}
|
|
|
|
>
|
|
|
|
<div>
|
2022-11-15 16:38:31 +00:00
|
|
|
<OrderPage
|
|
|
|
baseUrl={baseUrl}
|
2022-11-21 12:56:29 +00:00
|
|
|
order={order}
|
2022-11-24 17:42:30 +00:00
|
|
|
settings={settings}
|
2022-11-21 12:56:29 +00:00
|
|
|
setOrder={setOrder}
|
|
|
|
setCurrentOrder={setCurrentOrder}
|
|
|
|
badOrder={badOrder}
|
|
|
|
locationOrderId={props.match.params.orderId}
|
|
|
|
setBadOrder={setBadOrder}
|
|
|
|
hasRobot={robot.avatarLoaded}
|
|
|
|
windowSize={{ ...windowSize, height: windowSize.height - navbarHeight }}
|
|
|
|
setPage={setPage}
|
2022-11-15 16:38:31 +00:00
|
|
|
/>
|
2022-10-30 19:13:01 +00:00
|
|
|
</div>
|
|
|
|
</Slide>
|
2022-10-20 18:06:16 +00:00
|
|
|
)}
|
|
|
|
/>
|
2022-10-30 19:13:01 +00:00
|
|
|
|
|
|
|
<Route path='/settings'>
|
|
|
|
<Slide
|
|
|
|
direction={page === 'settings' ? slideDirection.in : slideDirection.out}
|
|
|
|
in={page === 'settings'}
|
|
|
|
appear={slideDirection.in != undefined}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<SettingsPage
|
2023-02-10 13:28:26 +00:00
|
|
|
fav={fav}
|
|
|
|
setFav={setFav}
|
2022-10-30 19:13:01 +00:00
|
|
|
settings={settings}
|
|
|
|
setSettings={setSettings}
|
|
|
|
windowSize={{ ...windowSize, height: windowSize.height - navbarHeight }}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Slide>
|
|
|
|
</Route>
|
2022-10-20 18:06:16 +00:00
|
|
|
</Switch>
|
2022-10-30 19:13:01 +00:00
|
|
|
</Box>
|
2022-11-21 12:56:29 +00:00
|
|
|
<div style={{ alignContent: 'center', display: 'flex' }}>
|
|
|
|
<NavBar
|
|
|
|
nickname={robot.avatarLoaded ? robot.nickname : null}
|
|
|
|
color={settings.network === 'mainnet' ? 'primary' : 'secondary'}
|
|
|
|
width={windowSize.width}
|
|
|
|
height={navbarHeight}
|
|
|
|
page={page}
|
|
|
|
setPage={setPage}
|
|
|
|
open={open}
|
|
|
|
setOpen={setOpen}
|
|
|
|
closeAll={closeAll}
|
|
|
|
setSlideDirection={setSlideDirection}
|
|
|
|
currentOrder={currentOrder}
|
|
|
|
hasRobot={robot.avatarLoaded}
|
|
|
|
baseUrl={baseUrl}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-10-30 19:13:01 +00:00
|
|
|
<MainDialogs
|
|
|
|
open={open}
|
|
|
|
setOpen={setOpen}
|
|
|
|
setRobot={setRobot}
|
2022-11-07 10:13:02 +00:00
|
|
|
setPage={setPage}
|
|
|
|
setCurrentOrder={setCurrentOrder}
|
2022-10-30 19:13:01 +00:00
|
|
|
info={info}
|
|
|
|
robot={robot}
|
|
|
|
closeAll={closeAll}
|
2022-11-07 16:45:05 +00:00
|
|
|
baseUrl={baseUrl}
|
2022-10-30 19:13:01 +00:00
|
|
|
/>
|
2022-10-20 18:06:16 +00:00
|
|
|
</Router>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Main;
|