diff --git a/frontend/src/basic/BookPage/index.tsx b/frontend/src/basic/BookPage/index.tsx
index 8ba12f2a..d96960ef 100644
--- a/frontend/src/basic/BookPage/index.tsx
+++ b/frontend/src/basic/BookPage/index.tsx
@@ -42,7 +42,7 @@ const BookPage = ({
windowSize,
hasRobot = false,
setPage = () => null,
- setOrder = () => null,
+ setCurrentOrder = () => null,
}: BookPageProps): JSX.Element => {
const { t } = useTranslation();
const history = useHistory();
@@ -76,7 +76,7 @@ const BookPage = ({
if (hasRobot) {
history.push('/order/' + id);
setPage('order');
- setOrder(id);
+ setCurrentOrder(id);
} else {
setOpenNoRobot(true);
}
@@ -125,6 +125,11 @@ const BookPage = ({
setFav={setFav}
setPage={setPage}
hasRobot={hasRobot}
+ onOrderCreated={(id) => {
+ setCurrentOrder(id);
+ setPage('order');
+ history.push('/order/' + id);
+ }}
/>
diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx
index 20453817..7f582022 100644
--- a/frontend/src/basic/Main.tsx
+++ b/frontend/src/basic/Main.tsx
@@ -340,6 +340,8 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
open={open}
setOpen={setOpen}
setRobot={setRobot}
+ setPage={setPage}
+ setCurrentOrder={setCurrentOrder}
info={info}
robot={robot}
closeAll={closeAll}
diff --git a/frontend/src/basic/MainDialogs/index.tsx b/frontend/src/basic/MainDialogs/index.tsx
index 5a64600e..f9a250aa 100644
--- a/frontend/src/basic/MainDialogs/index.tsx
+++ b/frontend/src/basic/MainDialogs/index.tsx
@@ -9,6 +9,7 @@ import {
StatsDialog,
UpdateClientDialog,
} from '../../components/Dialogs';
+import { Page } from '../NavBar';
export interface OpenDialogs {
more: boolean;
@@ -27,6 +28,8 @@ interface MainDialogsProps {
info: Info;
robot: Robot;
setRobot: (state: Robot) => void;
+ setPage: (state: Page) => void;
+ setCurrentOrder: (state: number) => void;
closeAll: OpenDialogs;
}
@@ -37,6 +40,8 @@ const MainDialogs = ({
closeAll,
robot,
setRobot,
+ setPage,
+ setCurrentOrder,
}: MainDialogsProps): JSX.Element => {
useEffect(() => {
if (info.openUpdateClient) {
@@ -77,6 +82,8 @@ const MainDialogs = ({
onClose={() => setOpen({ ...open, profile: false })}
robot={robot}
setRobot={setRobot}
+ setPage={setPage}
+ setCurrentOrder={setCurrentOrder}
/>
>
);
diff --git a/frontend/src/basic/NavBar/NavBar.tsx b/frontend/src/basic/NavBar/NavBar.tsx
index 6a9c36ca..bf207cd7 100644
--- a/frontend/src/basic/NavBar/NavBar.tsx
+++ b/frontend/src/basic/NavBar/NavBar.tsx
@@ -30,7 +30,7 @@ interface NavBarProps {
open: OpenDialogs;
setOpen: (state: OpenDialogs) => void;
closeAll: OpenDialogs;
- order: number | null;
+ currentOrder: number | null;
hasRobot: boolean;
}
@@ -44,7 +44,7 @@ const NavBar = ({
closeAll,
width,
height,
- order,
+ currentOrder,
hasRobot = false,
}: NavBarProps): JSX.Element => {
const theme = useTheme();
@@ -77,7 +77,7 @@ const NavBar = ({
} else {
handleSlideDirection(page, newPage);
setPage(newPage);
- const param = newPage === 'order' ? order ?? '' : '';
+ const param = newPage === 'order' ? currentOrder ?? '' : '';
setTimeout(
() => history.push(`/${newPage}/${param}`),
theme.transitions.duration.leavingScreen * 3,
@@ -144,7 +144,7 @@ const NavBar = ({
sx={tabSx}
label={smallBar ? undefined : t('Order')}
value='order'
- disabled={!hasRobot || order == null}
+ disabled={!hasRobot || currentOrder == null}
icon={}
iconPosition='start'
/>
diff --git a/frontend/src/components/Dialogs/Profile.tsx b/frontend/src/components/Dialogs/Profile.tsx
index 7250a5ea..6dcab0bb 100644
--- a/frontend/src/components/Dialogs/Profile.tsx
+++ b/frontend/src/components/Dialogs/Profile.tsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useTheme } from '@mui/material/styles';
-import { Link as LinkRouter } from 'react-router-dom';
+import { useHistory } from 'react-router-dom';
import {
Badge,
@@ -41,16 +41,27 @@ import { getHost, getWebln } from '../../utils';
import RobotAvatar from '../RobotAvatar';
import { apiClient } from '../../services/api';
import { Robot } from '../../models';
+import { Page } from '../../basic/NavBar';
interface Props {
open: boolean;
onClose: () => void;
robot: Robot;
setRobot: (state: Robot) => void;
+ setPage: (state: Page) => void;
+ setCurrentOrder: (state: number) => void;
}
-const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.Element => {
+const ProfileDialog = ({
+ open = false,
+ onClose,
+ robot,
+ setRobot,
+ setPage,
+ setCurrentOrder,
+}: Props): JSX.Element => {
const { t } = useTranslation();
+ const history = useHistory();
const theme = useTheme();
const host = getHost();
@@ -179,9 +190,12 @@ const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.E
{robot.activeOrderId ? (
{
+ history.push('/order/' + robot.activeOrderId);
+ setPage('order');
+ setCurrentOrder(robot.activeOrderId);
+ onClose();
+ }}
>
@@ -195,9 +209,12 @@ const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.E
) : robot.lastOrderId ? (
{
+ history.push('/order/' + robot.lastOrderId);
+ setPage('order');
+ setCurrentOrder(robot.lastOrderId);
+ onClose();
+ }}
>