From 017a008dcb8c6c36b86c64f7cb4559a2ff6c558f Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 17 Jul 2025 16:25:56 +0200 Subject: [PATCH] New mobile views --- frontend/src/basic/BookPage/index.tsx | 18 ++++-- frontend/src/basic/MakerPage/index.tsx | 7 ++- frontend/src/basic/OrderPage/index.tsx | 12 +++- frontend/src/basic/Routes.tsx | 59 ++++--------------- .../src/components/BookTable/BookControl.tsx | 38 +++++++----- frontend/src/components/Dialogs/GoToOrder.tsx | 6 +- frontend/src/components/Dialogs/NoRobot.tsx | 2 +- .../MakerForm/AutocompletePayments.tsx | 2 +- .../src/components/MakerForm/MakerForm.tsx | 4 +- .../src/components/Notifications/index.tsx | 5 +- .../components/OrderDetails/TakeButton.tsx | 4 +- frontend/src/components/RobotInfo/index.tsx | 2 +- frontend/src/components/TradeBox/index.tsx | 5 +- frontend/src/contexts/AppContext.tsx | 11 ++-- 14 files changed, 83 insertions(+), 92 deletions(-) diff --git a/frontend/src/basic/BookPage/index.tsx b/frontend/src/basic/BookPage/index.tsx index 91194d3e..15541387 100644 --- a/frontend/src/basic/BookPage/index.tsx +++ b/frontend/src/basic/BookPage/index.tsx @@ -16,7 +16,7 @@ import { type PublicOrder } from '../../models'; import GoToOrder from '../../components/Dialogs/GoToOrder'; const BookPage = (): React.JSX.Element => { - const { windowSize } = useContext(AppContext); + const { windowSize, navigateToPage } = useContext(AppContext); const { federation } = useContext(FederationContext); const theme = useTheme(); const { t } = useTranslation(); @@ -43,7 +43,7 @@ const BookPage = (): React.JSX.Element => { setOpenVisitThirdParty(true); } } else { - navigate(`/order/${shortAlias}/${id}`); + navigateToPage(`order/${shortAlias}/${id}`, navigate); } }; @@ -97,7 +97,13 @@ const BookPage = (): React.JSX.Element => { }; return ( - + { @@ -151,19 +157,19 @@ const BookPage = (): React.JSX.Element => { ) : view === 'depth' ? ( ) : view === 'map' ? ( ) : ( { - const { fav, windowSize, navbarHeight } = useContext(AppContext); + const { fav, windowSize, navbarHeight, navigateToPage } = useContext(AppContext); const { federation } = useContext(FederationContext); const { garage, maker } = useContext(GarageContext); const { t } = useTranslation(); @@ -68,7 +68,7 @@ const MakerPage = (): React.JSX.Element => { } } else { if (garage.getSlot()?.hashId) { - navigate(`/order/${shortAlias}/${id}`); + navigateToPage(`order/${shortAlias}/${id}`, navigate); } else { setClickedOrder({ id, shortAlias }); setOpenNoRobot(true); @@ -96,7 +96,8 @@ const MakerPage = (): React.JSX.Element => { .createRobot(federation, token) .then(() => { setOpenNoRobot(true); - if (clickedOrder) navigate(`/order/${clickedOrder?.shortAlias}/${clickedOrder?.id}`); + if (clickedOrder) + navigateToPage(`order/${clickedOrder?.shortAlias}/${clickedOrder?.id}`, navigate); }) .catch((e) => { console.log(e); diff --git a/frontend/src/basic/OrderPage/index.tsx b/frontend/src/basic/OrderPage/index.tsx index 87087149..fcbc0331 100644 --- a/frontend/src/basic/OrderPage/index.tsx +++ b/frontend/src/basic/OrderPage/index.tsx @@ -25,8 +25,14 @@ import { type UseGarageStoreType, GarageContext } from '../../contexts/GarageCon import { genBase62Token } from '../../utils'; const OrderPage = (): React.JSX.Element => { - const { windowSize, setOpen, acknowledgedWarning, setAcknowledgedWarning, navbarHeight } = - useContext(AppContext); + const { + windowSize, + setOpen, + acknowledgedWarning, + setAcknowledgedWarning, + navbarHeight, + navigateToPage, + } = useContext(AppContext); const { federation } = useContext(FederationContext); const { garage } = useContext(GarageContext); const { t } = useTranslation(); @@ -100,7 +106,7 @@ const OrderPage = (): React.JSX.Element => { }; const startAgain = (): void => { - navigate('/garage'); + navigateToPage('order', navigate); }; const orderDetailsSpace = currentOrder ? ( diff --git a/frontend/src/basic/Routes.tsx b/frontend/src/basic/Routes.tsx index b92b0f19..11cbf13a 100644 --- a/frontend/src/basic/Routes.tsx +++ b/frontend/src/basic/Routes.tsx @@ -1,20 +1,15 @@ -import React, { useContext, useEffect, useState } from 'react'; +import React, { useContext, useEffect } from 'react'; import { Routes as DomRoutes, Route, useNavigate } from 'react-router-dom'; -import { Slide, type SlideProps } from '@mui/material'; +import { Fade } from '@mui/material'; import { type UseAppStoreType, AppContext, Page } from '../contexts/AppContext'; import { RobotPage, MakerPage, BookPage, OrderPage, SettingsPage } from '.'; import { GarageContext, type UseGarageStoreType } from '../contexts/GarageContext'; -// Define the page order for carousel effect -const pageOrder: Page[] = ['garage', 'offers', 'create', 'order', 'settings']; - const Routes: React.FC = () => { const navigate = useNavigate(); const { garage } = useContext(GarageContext); const { page, navigateToPage } = useContext(AppContext); - const [prevPage, setPrevPage] = useState('none'); - const [slideDirection, setSlideDirection] = useState('left'); useEffect(() => { window.addEventListener('navigateToPage', (event) => { @@ -24,7 +19,7 @@ const Routes: React.FC = () => { const slot = garage.getSlotByOrder(coordinator, parseInt(orderId, 10)); if (slot?.token) { garage.setCurrentSlot(slot?.token); - navigate(`/order/${coordinator}/${orderId}`); + navigateToPage(`order/${coordinator}/${orderId}`, navigate); } } }); @@ -35,37 +30,9 @@ const Routes: React.FC = () => { const pathPage: Page | string = location.pathname.split('/')[1]; if (pathPage === 'index.html') { navigateToPage('garage', navigate); - } else { - navigateToPage(pathPage as Page, navigate); } }, [location]); - // Determine slide direction based on page order (carousel effect) - useEffect(() => { - if (prevPage === 'none' || page === prevPage) { - // Initial load or same page, default direction - setSlideDirection('left'); - } else { - const prevIndex = pageOrder.indexOf(prevPage); - const currentIndex = pageOrder.indexOf(page); - - // If moving forward in the carousel (or wrapping from end to start) - if (currentIndex > prevIndex || (prevIndex === pageOrder.length - 1 && currentIndex === 0)) { - setSlideDirection('left'); // New page comes from right - } - // If moving backward in the carousel (or wrapping from start to end) - else if ( - currentIndex < prevIndex || - (prevIndex === 0 && currentIndex === pageOrder.length - 1) - ) { - setSlideDirection('right'); // New page comes from left - } - } - - // Update previous page after determining direction - setPrevPage(page); - }, [page]); - return ( {['/garage/:token?', '/garage', '/', ''].map((path, index) => { @@ -73,11 +40,11 @@ const Routes: React.FC = () => { +
- +
} key={index} /> @@ -87,44 +54,44 @@ const Routes: React.FC = () => { +
- +
} /> +
- +
} /> +
- +
} /> +
- +
} />
diff --git a/frontend/src/components/BookTable/BookControl.tsx b/frontend/src/components/BookTable/BookControl.tsx index b91b83ce..9f7bdda6 100644 --- a/frontend/src/components/BookTable/BookControl.tsx +++ b/frontend/src/components/BookTable/BookControl.tsx @@ -32,8 +32,8 @@ const BookControl = ({ const theme = useTheme(); const [orderType, setOrderType] = useState('any'); - const [small, medium, large] = useMemo(() => { - const small = fav.mode === 'fiat' ? 16 : 7.5; + const [_small, medium, large] = useMemo(() => { + const small = 16; const medium = small + 13; const large = medium + (t('and use').length + t('pay with').length) * 0.6 + 5; return [small, medium, large]; @@ -270,21 +270,21 @@ const BookControl = ({ tagProps={{ sx: { height: '1.8em' } }} listBoxProps={{ sx: { width: '13em' } }} onAutocompleteChange={setPaymentMethods} - value={paymentMethod} + paymentMethods={paymentMethod} + paymentMethodsText={paymentMethod.join(' ')} optionsType={fav.currency === 1000 ? 'swap' : 'fiat'} error={false} - helperText={''} label={fav.currency === 1000 ? t('DESTINATION') : t('METHOD')} tooltipTitle='' addNewButtonText='' isFilter={true} multiple={true} - optionsDisplayLimit={1} + listHeaderText={''} />
) : null} - {width > small && width <= medium ? ( + {width <= medium ? (