Fix navigation

This commit is contained in:
Reckless_Satoshi 2024-01-14 16:38:28 +00:00
parent 017601c478
commit 9d8c8d5e0d
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 10 additions and 5 deletions

View File

@ -14,7 +14,7 @@ import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageCon
const MakerPage = (): JSX.Element => {
const { fav, windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);
const { federation } = useContext<UseFederationStoreType>(FederationContext);
const { federation, setDelay } = useContext<UseFederationStoreType>(FederationContext);
const { garage, maker } = useContext<UseGarageStoreType>(GarageContext);
const { t } = useTranslation();
const navigate = useNavigate();
@ -50,9 +50,10 @@ const MakerPage = (): JSX.Element => {
maker.paymentMethods,
]);
const onOrderClicked = function (id: number): void {
const onOrderClicked = function (id: number, shortAlias: string): void {
if (garage.getSlot()?.hashId) {
navigate(`/order/${id}`);
setDelay(10000);
navigate(`/order/${shortAlias}/${id}`);
} else {
setOpenNoRobot(true);
}

View File

@ -46,6 +46,10 @@ const NavBar = (): JSX.Element => {
settings: 5,
};
useEffect(() => {
// re-render on orde rand robot updated at for latest orderId in tab
}, [robotUpdatedAt]);
useEffect(() => {
// change tab (page) into the current route
const pathPage: Page | string = location.pathname.split('/')[1];
@ -53,10 +57,10 @@ const NavBar = (): JSX.Element => {
navigate('/robot');
setPage('robot');
}
if (isPage(pathPage) && pathPage.includes('order')) {
if (isPage(pathPage)) {
setPage(pathPage);
}
}, [location, navigate, orderUpdatedAt, robotUpdatedAt]);
}, [location]);
const handleSlideDirection = function (oldPage: Page, newPage: Page): void {
const oldPos: number = pagesPosition[oldPage];