Fix blank route and loading spinner on order page change

This commit is contained in:
Reckless_Satoshi 2023-04-27 02:57:52 -07:00
parent d0450fc07d
commit 91bbc4c9f5
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 13 additions and 3 deletions

View File

@ -54,8 +54,11 @@ const NavBar = ({ width, height }: NavBarProps): JSX.Element => {
}; };
useEffect(() => { useEffect(() => {
const pathPage = location.pathname.split('/')[1]; // change tab (page) into the current route
setPage(pathPage); const pathPage: Page = location.pathname.split('/')[1];
if (pathPage) {
setPage(pathPage);
}
}, [location]); }, [location]);
const handleSlideDirection = function (oldPage: Page, newPage: Page) { const handleSlideDirection = function (oldPage: Page, newPage: Page) {

View File

@ -17,6 +17,8 @@ const OrderPage = (): JSX.Element => {
robot, robot,
settings, settings,
setOrder, setOrder,
clearOrder,
currentOrder,
setCurrentOrder, setCurrentOrder,
badOrder, badOrder,
setBadOrder, setBadOrder,
@ -32,7 +34,12 @@ const OrderPage = (): JSX.Element => {
const [tab, setTab] = useState<'order' | 'contract'>('contract'); const [tab, setTab] = useState<'order' | 'contract'>('contract');
useEffect(() => setCurrentOrder(Number(params.orderId)), [params.orderId]); useEffect(() => {
setCurrentOrder(Number(params.orderId));
if (currentOrder != params.orderId) {
clearOrder();
}
}, [params.orderId]);
const renewOrder = function () { const renewOrder = function () {
if (order != undefined) { if (order != undefined) {