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,
|
||||
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);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Dialog>
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
@ -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={<Assignment />}
|
||||
iconPosition='start'
|
||||
/>
|
||||
|
@ -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 ? (
|
||||
<ListItemButton
|
||||
onClick={onClose}
|
||||
to={`/order/${robot.activeOrderId}`}
|
||||
component={LinkRouter}
|
||||
onClick={() => {
|
||||
history.push('/order/' + robot.activeOrderId);
|
||||
setPage('order');
|
||||
setCurrentOrder(robot.activeOrderId);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<Badge badgeContent='' color='primary'>
|
||||
@ -195,9 +209,12 @@ const ProfileDialog = ({ open = false, onClose, robot, setRobot }: Props): JSX.E
|
||||
</ListItemButton>
|
||||
) : robot.lastOrderId ? (
|
||||
<ListItemButton
|
||||
onClick={onClose}
|
||||
to={`/order/${robot.lastOrderId}`}
|
||||
component={LinkRouter}
|
||||
onClick={() => {
|
||||
history.push('/order/' + robot.lastOrderId);
|
||||
setPage('order');
|
||||
setCurrentOrder(robot.lastOrderId);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<NumbersIcon color='primary' />
|
||||
|
Loading…
Reference in New Issue
Block a user