mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-10 16:21:36 +00:00
Fix maker on book page
This commit is contained in:
parent
87e0a8b4ae
commit
4473923286
@ -42,7 +42,7 @@ const BookPage = ({
|
|||||||
windowSize,
|
windowSize,
|
||||||
hasRobot = false,
|
hasRobot = false,
|
||||||
setPage = () => null,
|
setPage = () => null,
|
||||||
setOrder = () => null,
|
setCurrentOrder = () => null,
|
||||||
}: BookPageProps): JSX.Element => {
|
}: BookPageProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -76,7 +76,7 @@ const BookPage = ({
|
|||||||
if (hasRobot) {
|
if (hasRobot) {
|
||||||
history.push('/order/' + id);
|
history.push('/order/' + id);
|
||||||
setPage('order');
|
setPage('order');
|
||||||
setOrder(id);
|
setCurrentOrder(id);
|
||||||
} else {
|
} else {
|
||||||
setOpenNoRobot(true);
|
setOpenNoRobot(true);
|
||||||
}
|
}
|
||||||
@ -125,6 +125,11 @@ const BookPage = ({
|
|||||||
setFav={setFav}
|
setFav={setFav}
|
||||||
setPage={setPage}
|
setPage={setPage}
|
||||||
hasRobot={hasRobot}
|
hasRobot={hasRobot}
|
||||||
|
onOrderCreated={(id) => {
|
||||||
|
setCurrentOrder(id);
|
||||||
|
setPage('order');
|
||||||
|
history.push('/order/' + id);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
@ -340,6 +340,8 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
open={open}
|
open={open}
|
||||||
setOpen={setOpen}
|
setOpen={setOpen}
|
||||||
setRobot={setRobot}
|
setRobot={setRobot}
|
||||||
|
setPage={setPage}
|
||||||
|
setCurrentOrder={setCurrentOrder}
|
||||||
info={info}
|
info={info}
|
||||||
robot={robot}
|
robot={robot}
|
||||||
closeAll={closeAll}
|
closeAll={closeAll}
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
StatsDialog,
|
StatsDialog,
|
||||||
UpdateClientDialog,
|
UpdateClientDialog,
|
||||||
} from '../../components/Dialogs';
|
} from '../../components/Dialogs';
|
||||||
|
import { Page } from '../NavBar';
|
||||||
|
|
||||||
export interface OpenDialogs {
|
export interface OpenDialogs {
|
||||||
more: boolean;
|
more: boolean;
|
||||||
@ -27,6 +28,8 @@ interface MainDialogsProps {
|
|||||||
info: Info;
|
info: Info;
|
||||||
robot: Robot;
|
robot: Robot;
|
||||||
setRobot: (state: Robot) => void;
|
setRobot: (state: Robot) => void;
|
||||||
|
setPage: (state: Page) => void;
|
||||||
|
setCurrentOrder: (state: number) => void;
|
||||||
closeAll: OpenDialogs;
|
closeAll: OpenDialogs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +40,8 @@ const MainDialogs = ({
|
|||||||
closeAll,
|
closeAll,
|
||||||
robot,
|
robot,
|
||||||
setRobot,
|
setRobot,
|
||||||
|
setPage,
|
||||||
|
setCurrentOrder,
|
||||||
}: MainDialogsProps): JSX.Element => {
|
}: MainDialogsProps): JSX.Element => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (info.openUpdateClient) {
|
if (info.openUpdateClient) {
|
||||||
@ -77,6 +82,8 @@ const MainDialogs = ({
|
|||||||
onClose={() => setOpen({ ...open, profile: false })}
|
onClose={() => setOpen({ ...open, profile: false })}
|
||||||
robot={robot}
|
robot={robot}
|
||||||
setRobot={setRobot}
|
setRobot={setRobot}
|
||||||
|
setPage={setPage}
|
||||||
|
setCurrentOrder={setCurrentOrder}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -30,7 +30,7 @@ interface NavBarProps {
|
|||||||
open: OpenDialogs;
|
open: OpenDialogs;
|
||||||
setOpen: (state: OpenDialogs) => void;
|
setOpen: (state: OpenDialogs) => void;
|
||||||
closeAll: OpenDialogs;
|
closeAll: OpenDialogs;
|
||||||
order: number | null;
|
currentOrder: number | null;
|
||||||
hasRobot: boolean;
|
hasRobot: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ const NavBar = ({
|
|||||||
closeAll,
|
closeAll,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
order,
|
currentOrder,
|
||||||
hasRobot = false,
|
hasRobot = false,
|
||||||
}: NavBarProps): JSX.Element => {
|
}: NavBarProps): JSX.Element => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -77,7 +77,7 @@ const NavBar = ({
|
|||||||
} else {
|
} else {
|
||||||
handleSlideDirection(page, newPage);
|
handleSlideDirection(page, newPage);
|
||||||
setPage(newPage);
|
setPage(newPage);
|
||||||
const param = newPage === 'order' ? order ?? '' : '';
|
const param = newPage === 'order' ? currentOrder ?? '' : '';
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => history.push(`/${newPage}/${param}`),
|
() => history.push(`/${newPage}/${param}`),
|
||||||
theme.transitions.duration.leavingScreen * 3,
|
theme.transitions.duration.leavingScreen * 3,
|
||||||
@ -144,7 +144,7 @@ const NavBar = ({
|
|||||||
sx={tabSx}
|
sx={tabSx}
|
||||||
label={smallBar ? undefined : t('Order')}
|
label={smallBar ? undefined : t('Order')}
|
||||||
value='order'
|
value='order'
|
||||||
disabled={!hasRobot || order == null}
|
disabled={!hasRobot || currentOrder == null}
|
||||||
icon={<Assignment />}
|
icon={<Assignment />}
|
||||||
iconPosition='start'
|
iconPosition='start'
|
||||||
/>
|
/>
|
||||||
|
@ -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 { useTheme } from '@mui/material/styles';
|
import { useTheme } from '@mui/material/styles';
|
||||||
import { Link as LinkRouter } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
@ -41,16 +41,27 @@ import { getHost, getWebln } from '../../utils';
|
|||||||
import RobotAvatar from '../RobotAvatar';
|
import RobotAvatar from '../RobotAvatar';
|
||||||
import { apiClient } from '../../services/api';
|
import { apiClient } from '../../services/api';
|
||||||
import { Robot } from '../../models';
|
import { Robot } from '../../models';
|
||||||
|
import { Page } from '../../basic/NavBar';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
robot: Robot;
|
robot: Robot;
|
||||||
setRobot: (state: Robot) => void;
|
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 { t } = useTranslation();
|
||||||
|
const history = useHistory();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const host = getHost();
|
const host = getHost();
|
||||||
|
|
||||||
@ -179,9 +190,12 @@ const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.E
|
|||||||
|
|
||||||
{robot.activeOrderId ? (
|
{robot.activeOrderId ? (
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
onClick={onClose}
|
onClick={() => {
|
||||||
to={`/order/${robot.activeOrderId}`}
|
history.push('/order/' + robot.activeOrderId);
|
||||||
component={LinkRouter}
|
setPage('order');
|
||||||
|
setCurrentOrder(robot.activeOrderId);
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<Badge badgeContent='' color='primary'>
|
<Badge badgeContent='' color='primary'>
|
||||||
@ -195,9 +209,12 @@ const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.E
|
|||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
) : robot.lastOrderId ? (
|
) : robot.lastOrderId ? (
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
onClick={onClose}
|
onClick={() => {
|
||||||
to={`/order/${robot.lastOrderId}`}
|
history.push('/order/' + robot.lastOrderId);
|
||||||
component={LinkRouter}
|
setPage('order');
|
||||||
|
setCurrentOrder(robot.lastOrderId);
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<NumbersIcon color='primary' />
|
<NumbersIcon color='primary' />
|
||||||
|
Loading…
Reference in New Issue
Block a user