mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 19:36:24 +00:00
Refactor confirmation Dialogs
This commit is contained in:
parent
c660a5b0d1
commit
ca35d6b3d2
@ -1,15 +1,17 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Typography, Grid, ButtonGroup, Dialog, Box } from '@mui/material';
|
import { Button, Grid, ButtonGroup, Dialog, Box } from '@mui/material';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import DepthChart from '../../components/Charts/DepthChart';
|
import DepthChart from '../../components/Charts/DepthChart';
|
||||||
|
|
||||||
|
import { NoRobotDialog } from '../../components/Dialogs';
|
||||||
|
import MakerForm from '../../components/MakerForm';
|
||||||
|
import BookTable from '../../components/BookTable';
|
||||||
|
import { Page } from '../NavBar';
|
||||||
import { Book, Favorites, LimitList, Maker } from '../../models';
|
import { Book, Favorites, LimitList, Maker } from '../../models';
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
import { BarChart, FormatListBulleted } from '@mui/icons-material';
|
import { BarChart, FormatListBulleted } from '@mui/icons-material';
|
||||||
import MakerForm from '../../components/MakerForm';
|
|
||||||
import BookTable from '../../components/BookTable';
|
|
||||||
|
|
||||||
interface BookPageProps {
|
interface BookPageProps {
|
||||||
book: Book;
|
book: Book;
|
||||||
@ -22,6 +24,9 @@ interface BookPageProps {
|
|||||||
lastDayPremium: number;
|
lastDayPremium: number;
|
||||||
maker: Maker;
|
maker: Maker;
|
||||||
setMaker: (state: Maker) => void;
|
setMaker: (state: Maker) => void;
|
||||||
|
hasRobot: boolean;
|
||||||
|
setPage: (state: Page) => void;
|
||||||
|
setOrder: (state: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BookPage = ({
|
const BookPage = ({
|
||||||
@ -35,11 +40,15 @@ const BookPage = ({
|
|||||||
maker,
|
maker,
|
||||||
setMaker,
|
setMaker,
|
||||||
windowSize,
|
windowSize,
|
||||||
|
hasRobot = false,
|
||||||
|
setPage = () => null,
|
||||||
|
setOrder = () => null,
|
||||||
}: BookPageProps): JSX.Element => {
|
}: BookPageProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [view, setView] = useState<'list' | 'depth'>('list');
|
const [view, setView] = useState<'list' | 'depth'>('list');
|
||||||
const [openMaker, setOpenMaker] = useState<boolean>(false);
|
const [openMaker, setOpenMaker] = useState<boolean>(false);
|
||||||
|
const [openNoRobot, setOpenNoRobot] = useState<boolean>(false);
|
||||||
|
|
||||||
const doubleView = windowSize.width > 115;
|
const doubleView = windowSize.width > 115;
|
||||||
const width = windowSize.width * 0.9;
|
const width = windowSize.width * 0.9;
|
||||||
@ -63,6 +72,16 @@ const BookPage = ({
|
|||||||
setFav({ ...fav, type: val });
|
setFav({ ...fav, type: val });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onOrderClicked = function (id: number) {
|
||||||
|
if (hasRobot) {
|
||||||
|
history.push('/order/' + id);
|
||||||
|
setPage('order');
|
||||||
|
setOrder(id);
|
||||||
|
} else {
|
||||||
|
setOpenNoRobot(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const NavButtons = function () {
|
const NavButtons = function () {
|
||||||
return (
|
return (
|
||||||
<ButtonGroup variant='contained' color='inherit'>
|
<ButtonGroup variant='contained' color='inherit'>
|
||||||
@ -93,6 +112,7 @@ const BookPage = ({
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Grid container direction='column' alignItems='center' spacing={1} sx={{ minWidth: 400 }}>
|
<Grid container direction='column' alignItems='center' spacing={1} sx={{ minWidth: 400 }}>
|
||||||
|
<NoRobotDialog open={openNoRobot} onClose={() => setOpenNoRobot(false)} setPage={setPage} />
|
||||||
{openMaker ? (
|
{openMaker ? (
|
||||||
<Dialog open={openMaker} onClose={() => setOpenMaker(false)}>
|
<Dialog open={openMaker} onClose={() => setOpenMaker(false)}>
|
||||||
<Box sx={{ maxWidth: '18em', padding: '0.5em' }}>
|
<Box sx={{ maxWidth: '18em', padding: '0.5em' }}>
|
||||||
@ -103,6 +123,8 @@ const BookPage = ({
|
|||||||
setMaker={setMaker}
|
setMaker={setMaker}
|
||||||
fav={fav}
|
fav={fav}
|
||||||
setFav={setFav}
|
setFav={setFav}
|
||||||
|
setPage={setPage}
|
||||||
|
hasRobot={hasRobot}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
@ -130,6 +152,7 @@ const BookPage = ({
|
|||||||
defaultFullscreen={false}
|
defaultFullscreen={false}
|
||||||
onCurrencyChange={handleCurrencyChange}
|
onCurrencyChange={handleCurrencyChange}
|
||||||
onTypeChange={handleTypeChange}
|
onTypeChange={handleTypeChange}
|
||||||
|
onOrderClicked={onOrderClicked}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
@ -164,6 +187,7 @@ const BookPage = ({
|
|||||||
defaultFullscreen={false}
|
defaultFullscreen={false}
|
||||||
onCurrencyChange={handleCurrencyChange}
|
onCurrencyChange={handleCurrencyChange}
|
||||||
onTypeChange={handleTypeChange}
|
onTypeChange={handleTypeChange}
|
||||||
|
onOrderClicked={onOrderClicked}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -60,9 +60,14 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const Router = window.NativeRobosats != null ? HashRouter : BrowserRouter;
|
const Router = window.NativeRobosats != null ? HashRouter : BrowserRouter;
|
||||||
const basename = window.NativeRobosats != null ? window.location.pathname : '';
|
const basename = window.NativeRobosats != null ? window.location.pathname : '';
|
||||||
const [page, setPage] = useState<Page>(window.location.pathname.split('/')[1]);
|
const [page, setPage] = useState<Page>(
|
||||||
|
window.location.pathname.split('/')[1] == ''
|
||||||
|
? 'offers'
|
||||||
|
: window.location.pathname.split('/')[1],
|
||||||
|
);
|
||||||
const [slideDirection, setSlideDirection] = useState<SlideDirection>({
|
const [slideDirection, setSlideDirection] = useState<SlideDirection>({
|
||||||
in: undefined,
|
in: undefined,
|
||||||
out: undefined,
|
out: undefined,
|
||||||
@ -145,7 +150,6 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
apiClient.post('/api/user/', requestBody).then((data: any) => {
|
apiClient.post('/api/user/', requestBody).then((data: any) => {
|
||||||
console.log(data);
|
|
||||||
setOrder(
|
setOrder(
|
||||||
data.active_order_id
|
data.active_order_id
|
||||||
? data.active_order_id
|
? data.active_order_id
|
||||||
@ -182,12 +186,14 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
console.log(page);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router basename={basename}>
|
<Router basename={basename}>
|
||||||
{/* load robot avatar image, set avatarLoaded: true */}
|
{/* load robot avatar image, set avatarLoaded: true */}
|
||||||
<RobotAvatar
|
<RobotAvatar
|
||||||
style={{ display: 'none' }}
|
style={{ display: 'none' }}
|
||||||
nickname={robot.avatarLoaded ? robot.nickname : null}
|
nickname={robot.nickname}
|
||||||
onLoad={() => setRobot({ ...robot, avatarLoaded: true })}
|
onLoad={() => setRobot({ ...robot, avatarLoaded: true })}
|
||||||
/>
|
/>
|
||||||
<Box
|
<Box
|
||||||
@ -199,33 +205,30 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route
|
|
||||||
exact
|
|
||||||
path='/'
|
|
||||||
render={(props: any) => (
|
|
||||||
<UserGenPage
|
|
||||||
setPage={setPage}
|
|
||||||
match={props.match}
|
|
||||||
theme={theme}
|
|
||||||
robot={robot}
|
|
||||||
setRobot={setRobot}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Route
|
<Route
|
||||||
path='/robot/:refCode?'
|
path='/robot/:refCode?'
|
||||||
render={(props: any) => (
|
render={(props: any) => (
|
||||||
<UserGenPage
|
<Slide
|
||||||
setPage={setPage}
|
direction={page === 'robot' ? slideDirection.in : slideDirection.out}
|
||||||
match={props.match}
|
in={page === 'robot'}
|
||||||
theme={theme}
|
appear={slideDirection.in != undefined}
|
||||||
robot={robot}
|
>
|
||||||
setRobot={setRobot}
|
<div>
|
||||||
/>
|
<UserGenPage
|
||||||
|
setPage={setPage}
|
||||||
|
order={order}
|
||||||
|
setOrder={setOrder}
|
||||||
|
match={props.match}
|
||||||
|
theme={theme}
|
||||||
|
robot={robot}
|
||||||
|
setRobot={setRobot}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Slide>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Route path='/offers'>
|
<Route exact path={['/offers', '/']}>
|
||||||
<Slide
|
<Slide
|
||||||
direction={page === 'offers' ? slideDirection.in : slideDirection.out}
|
direction={page === 'offers' ? slideDirection.in : slideDirection.out}
|
||||||
in={page === 'offers'}
|
in={page === 'offers'}
|
||||||
@ -244,6 +247,8 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
lastDayPremium={info.last_day_nonkyc_btc_premium}
|
lastDayPremium={info.last_day_nonkyc_btc_premium}
|
||||||
windowSize={windowSize}
|
windowSize={windowSize}
|
||||||
hasRobot={robot.avatarLoaded}
|
hasRobot={robot.avatarLoaded}
|
||||||
|
setPage={setPage}
|
||||||
|
setOrder={setOrder}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Slide>
|
</Slide>
|
||||||
@ -275,7 +280,17 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
|
|
||||||
<Route
|
<Route
|
||||||
path='/order/:orderId'
|
path='/order/:orderId'
|
||||||
render={(props: any) => <OrderPage theme={theme} history={history} {...props} />}
|
render={(props: any) => (
|
||||||
|
<Slide
|
||||||
|
direction={page === 'order' ? slideDirection.in : slideDirection.out}
|
||||||
|
in={page === 'order'}
|
||||||
|
appear={slideDirection.in != undefined}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<OrderPage theme={theme} history={history} {...props} />
|
||||||
|
</div>
|
||||||
|
</Slide>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Route path='/settings'>
|
<Route path='/settings'>
|
||||||
@ -296,7 +311,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
</Switch>
|
</Switch>
|
||||||
</Box>
|
</Box>
|
||||||
<NavBar
|
<NavBar
|
||||||
nickname={robot.nickname}
|
nickname={robot.avatarLoaded ? robot.nickname : null}
|
||||||
width={windowSize.width}
|
width={windowSize.width}
|
||||||
height={navbarHeight}
|
height={navbarHeight}
|
||||||
page={page}
|
page={page}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Grid, Paper, Collapse, Typography } from '@mui/material';
|
import { Grid, Paper, Collapse, Typography } from '@mui/material';
|
||||||
|
|
||||||
import { LimitList, Maker, Book, Favorites } from '../../models';
|
import { LimitList, Maker, Book, Favorites } from '../../models';
|
||||||
|
|
||||||
@ -8,6 +8,7 @@ import { filterOrders } from '../../utils';
|
|||||||
|
|
||||||
import MakerForm from '../../components/MakerForm';
|
import MakerForm from '../../components/MakerForm';
|
||||||
import BookTable from '../../components/BookTable';
|
import BookTable from '../../components/BookTable';
|
||||||
|
|
||||||
import { Page } from '../NavBar';
|
import { Page } from '../NavBar';
|
||||||
|
|
||||||
interface MakerPageProps {
|
interface MakerPageProps {
|
||||||
@ -97,11 +98,13 @@ const MakerPage = ({
|
|||||||
setOrder(id);
|
setOrder(id);
|
||||||
setPage('order');
|
setPage('order');
|
||||||
}}
|
}}
|
||||||
|
hasRobot={hasRobot}
|
||||||
disableRequest={matches.length > 0 && !showMatches}
|
disableRequest={matches.length > 0 && !showMatches}
|
||||||
collapseAll={showMatches}
|
collapseAll={showMatches}
|
||||||
onSubmit={() => setShowMatches(matches.length > 0)}
|
onSubmit={() => setShowMatches(matches.length > 0)}
|
||||||
onReset={() => setShowMatches(false)}
|
onReset={() => setShowMatches(false)}
|
||||||
submitButtonLabel={matches.length > 0 && !showMatches ? 'Submit' : 'Create order'}
|
submitButtonLabel={matches.length > 0 && !showMatches ? 'Submit' : 'Create order'}
|
||||||
|
setPage={setPage}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { Tabs, Tab, Paper, useTheme } from '@mui/material';
|
import { Tabs, Tab, Paper, useTheme, Tooltip } from '@mui/material';
|
||||||
import MoreTooltip from './MoreTooltip';
|
import MoreTooltip from './MoreTooltip';
|
||||||
|
|
||||||
import { OpenDialogs } from '../MainDialogs';
|
import { OpenDialogs } from '../MainDialogs';
|
||||||
@ -24,7 +24,6 @@ interface NavBarProps {
|
|||||||
page: Page;
|
page: Page;
|
||||||
nickname?: string | null;
|
nickname?: string | null;
|
||||||
setPage: (state: Page) => void;
|
setPage: (state: Page) => void;
|
||||||
slideDirection: { in: Direction; out: Direction };
|
|
||||||
setSlideDirection: (state: { in: Direction; out: Direction }) => void;
|
setSlideDirection: (state: { in: Direction; out: Direction }) => void;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
@ -38,7 +37,6 @@ interface NavBarProps {
|
|||||||
const NavBar = ({
|
const NavBar = ({
|
||||||
page,
|
page,
|
||||||
setPage,
|
setPage,
|
||||||
slideDirection,
|
|
||||||
setSlideDirection,
|
setSlideDirection,
|
||||||
open,
|
open,
|
||||||
nickname = null,
|
nickname = null,
|
||||||
@ -54,8 +52,6 @@ const NavBar = ({
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const smallBar = width < 50;
|
const smallBar = width < 50;
|
||||||
|
|
||||||
const [newPage, setNewPage] = useState<Page>(history.location.pathname.split('/')[1]);
|
|
||||||
|
|
||||||
const tabSx = smallBar
|
const tabSx = smallBar
|
||||||
? { position: 'relative', bottom: nickname ? '0.8em' : '0em', minWidth: '1em' }
|
? { position: 'relative', bottom: nickname ? '0.8em' : '0em', minWidth: '1em' }
|
||||||
: { position: 'relative', bottom: '1em', minWidth: '2em' };
|
: { position: 'relative', bottom: '1em', minWidth: '2em' };
|
||||||
@ -80,7 +76,7 @@ const NavBar = ({
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
handleSlideDirection(page, newPage);
|
handleSlideDirection(page, newPage);
|
||||||
setNewPage(newPage);
|
setPage(newPage);
|
||||||
const param = newPage === 'order' ? order ?? '' : '';
|
const param = newPage === 'order' ? order ?? '' : '';
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => history.push(`/${newPage}/${param}`),
|
() => history.push(`/${newPage}/${param}`),
|
||||||
@ -89,10 +85,6 @@ const NavBar = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setPage(newPage);
|
|
||||||
}, [slideDirection, newPage]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setOpen(closeAll);
|
setOpen(closeAll);
|
||||||
}, [page]);
|
}, [page]);
|
||||||
@ -151,7 +143,7 @@ const NavBar = ({
|
|||||||
sx={tabSx}
|
sx={tabSx}
|
||||||
label={smallBar ? undefined : t('Order')}
|
label={smallBar ? undefined : t('Order')}
|
||||||
value='order'
|
value='order'
|
||||||
disabled={!hasRobot}
|
disabled={!hasRobot || order == null}
|
||||||
icon={<Assignment />}
|
icon={<Assignment />}
|
||||||
iconPosition='start'
|
iconPosition='start'
|
||||||
/>
|
/>
|
||||||
@ -168,6 +160,7 @@ const NavBar = ({
|
|||||||
label={smallBar ? undefined : t('More')}
|
label={smallBar ? undefined : t('More')}
|
||||||
value='none'
|
value='none'
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
console.log(e);
|
||||||
open.more ? null : setOpen({ ...open, more: true });
|
open.more ? null : setOpen({ ...open, more: true });
|
||||||
}}
|
}}
|
||||||
icon={
|
icon={
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import NavBar from './NavBar';
|
import NavBar from './NavBar';
|
||||||
|
|
||||||
export type Page = 'robot' | 'order' | 'create' | 'offers' | 'settings' | 'none';
|
export type Page = 'robot' | 'order' | 'create' | 'offers' | 'settings' | 'none';
|
||||||
export type { OpenDialogs } from './MoreTooltip';
|
|
||||||
export default NavBar;
|
export default NavBar;
|
||||||
|
@ -70,10 +70,16 @@ class UserGenPage extends Component {
|
|||||||
ref_code: refCode,
|
ref_code: refCode,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
requestBody.then((body) => console.log(body));
|
|
||||||
requestBody.then((body) =>
|
requestBody.then((body) =>
|
||||||
apiClient.post('/api/user/', body).then((data) => {
|
apiClient.post('/api/user/', body).then((data) => {
|
||||||
this.setState({ found: data.found, bad_request: data.bad_request });
|
this.setState({ found: data.found, bad_request: data.bad_request });
|
||||||
|
this.props.setOrder(
|
||||||
|
data.active_order_id
|
||||||
|
? data.active_order_id
|
||||||
|
: data.last_order_id
|
||||||
|
? data.last_order_id
|
||||||
|
: this.props.order,
|
||||||
|
);
|
||||||
// Add nick and token to App state (token only if not a bad request)
|
// Add nick and token to App state (token only if not a bad request)
|
||||||
data.bad_request
|
data.bad_request
|
||||||
? this.props.setRobot({
|
? this.props.setRobot({
|
||||||
|
@ -29,7 +29,7 @@ import RobotAvatar from '../RobotAvatar';
|
|||||||
// Icons
|
// Icons
|
||||||
import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material';
|
import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material';
|
||||||
|
|
||||||
interface Props {
|
interface BookTableProps {
|
||||||
clickRefresh?: () => void;
|
clickRefresh?: () => void;
|
||||||
book: Book;
|
book: Book;
|
||||||
fav?: Favorites;
|
fav?: Favorites;
|
||||||
@ -45,16 +45,17 @@ interface Props {
|
|||||||
showNoResults?: boolean;
|
showNoResults?: boolean;
|
||||||
onCurrencyChange?: (e: any) => void;
|
onCurrencyChange?: (e: any) => void;
|
||||||
onTypeChange?: (mouseEvent: any, val: number) => void;
|
onTypeChange?: (mouseEvent: any, val: number) => void;
|
||||||
|
onOrderClicked?: (id: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BookTable = ({
|
const BookTable = ({
|
||||||
clickRefresh,
|
clickRefresh,
|
||||||
book,
|
book,
|
||||||
fav,
|
fav = { currency: 1, type: 0 },
|
||||||
maxWidth,
|
maxWidth = 100,
|
||||||
maxHeight,
|
maxHeight = 70,
|
||||||
fullWidth,
|
fullWidth = 100,
|
||||||
fullHeight,
|
fullHeight = 70,
|
||||||
defaultFullscreen = false,
|
defaultFullscreen = false,
|
||||||
elevation = 6,
|
elevation = 6,
|
||||||
fillContainer = false,
|
fillContainer = false,
|
||||||
@ -63,7 +64,8 @@ const BookTable = ({
|
|||||||
showNoResults = true,
|
showNoResults = true,
|
||||||
onCurrencyChange,
|
onCurrencyChange,
|
||||||
onTypeChange,
|
onTypeChange,
|
||||||
}: Props): JSX.Element => {
|
onOrderClicked = () => null,
|
||||||
|
}: BookTableProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -753,7 +755,7 @@ const BookTable = ({
|
|||||||
setPageSize(newPageSize);
|
setPageSize(newPageSize);
|
||||||
setUseDefaultPageSize(false);
|
setUseDefaultPageSize(false);
|
||||||
}}
|
}}
|
||||||
onRowClick={(params: any) => history.push('/order/' + params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
onRowClick={(params: any) => onOrderClicked(params.row.id)}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
|
@ -36,7 +36,7 @@ interface DepthChartProps {
|
|||||||
maxWidth: number;
|
maxWidth: number;
|
||||||
maxHeight: number;
|
maxHeight: number;
|
||||||
fillContainer?: boolean;
|
fillContainer?: boolean;
|
||||||
elevation: number;
|
elevation?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DepthChart: React.FC<DepthChartProps> = ({
|
const DepthChart: React.FC<DepthChartProps> = ({
|
||||||
|
32
frontend/src/components/Dialogs/Confirmation.tsx
Normal file
32
frontend/src/components/Dialogs/Confirmation.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { NoRobotDialog, StoreTokenDialog } from '.';
|
||||||
|
import { Page } from '../../basic/NavBar';
|
||||||
|
|
||||||
|
interface ConfirmationDialogProps {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
setPage: (state: Page) => void;
|
||||||
|
onClickDone: () => void;
|
||||||
|
hasRobot: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ConfirmationDialog = ({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
hasRobot,
|
||||||
|
setPage,
|
||||||
|
onClickDone,
|
||||||
|
}: ConfirmationDialogProps): JSX.Element => {
|
||||||
|
return hasRobot ? (
|
||||||
|
<StoreTokenDialog
|
||||||
|
open={open}
|
||||||
|
onClose={onClose}
|
||||||
|
onClickBack={onClose}
|
||||||
|
onClickDone={onClickDone}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<NoRobotDialog open={open} onClose={onClose} setPage={setPage} />
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ConfirmationDialog;
|
@ -8,15 +8,24 @@ import {
|
|||||||
DialogContentText,
|
DialogContentText,
|
||||||
Button,
|
Button,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { Link } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import { Page } from '../../basic/NavBar';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
setPage: (state: Page) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NoRobotDialog = ({ open, onClose }: Props): JSX.Element => {
|
const NoRobotDialog = ({ open, onClose, setPage }: Props): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
const handleClickGenerate = function () {
|
||||||
|
onClose();
|
||||||
|
setPage('robot');
|
||||||
|
history.push('/robot');
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onClose={onClose}>
|
<Dialog open={open} onClose={onClose}>
|
||||||
@ -24,17 +33,12 @@ const NoRobotDialog = ({ open, onClose }: Props): JSX.Element => {
|
|||||||
|
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText>
|
<DialogContentText>
|
||||||
{t('You need to generate a robot avatar in order to become an order maker')}
|
{t('Generate a robot avatar first. Then create your own order.')}
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={onClose} autoFocus>
|
<Button onClick={handleClickGenerate}>{t('Generate Robot')}</Button>
|
||||||
{t('Go back')}
|
|
||||||
</Button>
|
|
||||||
<Button onClick={onClose} to='/' component={Link}>
|
|
||||||
{t('Generate Robot')}
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
@ -18,20 +18,11 @@ import ContentCopy from '@mui/icons-material/ContentCopy';
|
|||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
copyIconColor: string;
|
|
||||||
onClickCopy: () => void;
|
|
||||||
onClickBack: () => void;
|
onClickBack: () => void;
|
||||||
onClickDone: () => void;
|
onClickDone: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StoreTokenDialog = ({
|
const StoreTokenDialog = ({ open, onClose, onClickBack, onClickDone }: Props): JSX.Element => {
|
||||||
open,
|
|
||||||
onClose,
|
|
||||||
copyIconColor,
|
|
||||||
onClickCopy,
|
|
||||||
onClickBack,
|
|
||||||
onClickDone,
|
|
||||||
}: Props): JSX.Element => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -45,7 +36,7 @@ const StoreTokenDialog = ({
|
|||||||
)}
|
)}
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
<br />
|
<br />
|
||||||
<Grid align='center'>
|
<Grid container>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{ width: '100%', maxWidth: '550px' }}
|
sx={{ width: '100%', maxWidth: '550px' }}
|
||||||
disabled
|
disabled
|
||||||
@ -56,8 +47,12 @@ const StoreTokenDialog = ({
|
|||||||
InputProps={{
|
InputProps={{
|
||||||
endAdornment: (
|
endAdornment: (
|
||||||
<Tooltip disableHoverListener enterTouchDelay={0} title={t('Copied!')}>
|
<Tooltip disableHoverListener enterTouchDelay={0} title={t('Copied!')}>
|
||||||
<IconButton onClick={onClickCopy}>
|
<IconButton
|
||||||
<ContentCopy color={copyIconColor} />
|
onClick={() =>
|
||||||
|
systemClient.copyToClipboard(systemClient.getCookie('robot_token'))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<ContentCopy color='primary' />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
),
|
),
|
||||||
|
@ -4,6 +4,7 @@ export { default as InfoDialog } from './Info';
|
|||||||
export { default as LearnDialog } from './Learn';
|
export { default as LearnDialog } from './Learn';
|
||||||
export { default as NoRobotDialog } from './NoRobot';
|
export { default as NoRobotDialog } from './NoRobot';
|
||||||
export { default as StoreTokenDialog } from './StoreToken';
|
export { default as StoreTokenDialog } from './StoreToken';
|
||||||
|
export { default as ConfirmationDialog } from './Confirmation';
|
||||||
export { default as CoordinatorSummaryDialog } from './CoordinatorSummary';
|
export { default as CoordinatorSummaryDialog } from './CoordinatorSummary';
|
||||||
export { default as ProfileDialog } from './Profile';
|
export { default as ProfileDialog } from './Profile';
|
||||||
export { default as StatsDialog } from './Stats';
|
export { default as StatsDialog } from './Stats';
|
||||||
|
@ -29,7 +29,7 @@ import { LimitList, Maker, Favorites, defaultMaker } from '../../models';
|
|||||||
import { LocalizationProvider, TimePicker } from '@mui/x-date-pickers';
|
import { LocalizationProvider, TimePicker } from '@mui/x-date-pickers';
|
||||||
import DateFnsUtils from '@date-io/date-fns';
|
import DateFnsUtils from '@date-io/date-fns';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { StoreTokenDialog, NoRobotDialog } from '../Dialogs';
|
import { StoreTokenDialog, NoRobotDialog, ConfirmationDialog } from '../Dialogs';
|
||||||
import { apiClient } from '../../services/api';
|
import { apiClient } from '../../services/api';
|
||||||
import { systemClient } from '../../services/System';
|
import { systemClient } from '../../services/System';
|
||||||
|
|
||||||
@ -41,6 +41,7 @@ import { pn } from '../../utils';
|
|||||||
|
|
||||||
import { SelfImprovement, Lock, HourglassTop, DeleteSweep, Edit } from '@mui/icons-material';
|
import { SelfImprovement, Lock, HourglassTop, DeleteSweep, Edit } from '@mui/icons-material';
|
||||||
import { LoadingButton } from '@mui/lab';
|
import { LoadingButton } from '@mui/lab';
|
||||||
|
import { Page } from '../../basic/NavBar';
|
||||||
|
|
||||||
interface MakerFormProps {
|
interface MakerFormProps {
|
||||||
limits: { list: LimitList; loading: boolean };
|
limits: { list: LimitList; loading: boolean };
|
||||||
@ -56,6 +57,8 @@ interface MakerFormProps {
|
|||||||
onReset?: () => void;
|
onReset?: () => void;
|
||||||
submitButtonLabel?: string;
|
submitButtonLabel?: string;
|
||||||
onOrderCreated?: (id: number) => void;
|
onOrderCreated?: (id: number) => void;
|
||||||
|
hasRobot?: boolean;
|
||||||
|
setPage?: (state: Page) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MakerForm = ({
|
const MakerForm = ({
|
||||||
@ -72,6 +75,8 @@ const MakerForm = ({
|
|||||||
onReset = () => {},
|
onReset = () => {},
|
||||||
submitButtonLabel = 'Create Order',
|
submitButtonLabel = 'Create Order',
|
||||||
onOrderCreated = () => null,
|
onOrderCreated = () => null,
|
||||||
|
hasRobot = true,
|
||||||
|
setPage = () => null,
|
||||||
}: MakerFormProps): JSX.Element => {
|
}: MakerFormProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -423,23 +428,15 @@ const MakerForm = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ConfirmationDialogs = function () {
|
|
||||||
return systemClient.getCookie('robot_token') ? (
|
|
||||||
<StoreTokenDialog
|
|
||||||
open={openDialogs}
|
|
||||||
onClose={() => setOpenDialogs(false)}
|
|
||||||
onClickCopy={() => systemClient.copyToClipboard(systemClient.getCookie('robot_token'))}
|
|
||||||
copyIconColor={'primary'}
|
|
||||||
onClickBack={() => setOpenDialogs(false)}
|
|
||||||
onClickDone={handleCreateOrder}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<NoRobotDialog open={openDialogs} onClose={() => setOpenDialogs(false)} />
|
|
||||||
);
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<ConfirmationDialogs />
|
<ConfirmationDialog
|
||||||
|
open={openDialogs}
|
||||||
|
onClose={() => setOpenDialogs(false)}
|
||||||
|
setPage={setPage}
|
||||||
|
onClickDone={handleCreateOrder}
|
||||||
|
hasRobot={hasRobot}
|
||||||
|
/>
|
||||||
<Collapse in={limits.list.length == 0}>
|
<Collapse in={limits.list.length == 0}>
|
||||||
<div style={{ display: limits.list.length == 0 ? '' : 'none' }}>
|
<div style={{ display: limits.list.length == 0 ? '' : 'none' }}>
|
||||||
<LinearProgress />
|
<LinearProgress />
|
||||||
|
Loading…
Reference in New Issue
Block a user