Skip to content

Commit

Permalink
fix: navigate to home page if no routes are found on a page
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Sep 14, 2022
1 parent d2b08be commit 4f22c8c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/widget/src/pages/SwapRoutesPage/SwapRoutesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@
import type { Route } from '@lifi/sdk';
import type { BoxProps } from '@mui/material';
import { useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useHeaderActionStore } from '../../components/Header';
import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
import {
SwapRouteCard,
SwapRouteCardSkeleton,
SwapRouteNotFoundCard,
} from '../../components/SwapRouteCard';
import { useSwapRoutes } from '../../hooks';
import { useNavigateBack, useSwapRoutes } from '../../hooks';
import { useSetExecutableRoute } from '../../stores';
import { navigationRoutes } from '../../utils';
import { Stack } from './SwapRoutesPage.style';

export const SwapRoutesPage: React.FC<BoxProps> = () => {
const navigate = useNavigate();
const { pathname } = useLocation();
const { navigateBack, navigate } = useNavigateBack();
const {
routes: swapRoutes,
isLoading,
Expand All @@ -37,7 +35,7 @@ export const SwapRoutesPage: React.FC<BoxProps> = () => {

useEffect(() => {
if (!swapRoutes?.length && !isLoading && !isFetching) {
navigate(pathname.substring(0, pathname.lastIndexOf('/')));
navigateBack();
}
// redirect to the home page if no routes are found on page reload
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit 4f22c8c

Please sign in to comment.