@lifi/widget 1.11.0 → 1.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/App.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Route, Routes } from 'react-router-dom';
2
+ import { useRoutes } from 'react-router-dom';
3
3
  import { AppProvider } from './AppProvider';
4
4
  import { AppContainer, FlexContainer } from './components/AppContainer';
5
5
  import { Header } from './components/Header';
@@ -19,5 +19,57 @@ export const App = ({ config }) => {
19
19
  return (_jsx(AppProvider, Object.assign({ config: config }, { children: _jsx(AppDefault, {}) })));
20
20
  };
21
21
  export const AppDefault = () => {
22
- return (_jsxs(AppContainer, { children: [_jsx(Header, {}), _jsx(FlexContainer, Object.assign({ disableGutters: true }, { children: _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsx(MainPage, {}) }), _jsx(Route, { path: navigationRoutes.selectWallet, element: _jsx(SelectWalletPage, {}) }), _jsx(Route, { path: navigationRoutes.settings, element: _jsx(SettingsPage, {}) }), _jsx(Route, { path: navigationRoutes.swapHistory, element: _jsx(SwapHistoryPage, {}) }), _jsx(Route, { path: navigationRoutes.swapDetails, element: _jsx(SwapDetailsPage, {}) }), _jsx(Route, { path: navigationRoutes.fromToken, element: _jsx(SelectTokenPage, { formType: "from" }) }), _jsx(Route, { path: navigationRoutes.toToken, element: _jsx(SelectTokenPage, { formType: "to" }) }), _jsx(Route, { path: navigationRoutes.swapRoutes, element: _jsx(SwapRoutesPage, {}) }), _jsx(Route, { path: navigationRoutes.swap, element: _jsx(SwapPage, {}) }), _jsx(Route, { path: "*", element: _jsx(NotFound, {}) })] }) })), _jsx(PoweredBy, {}), _jsx(Initializer, {})] }));
22
+ return (_jsxs(AppContainer, { children: [_jsx(Header, {}), _jsx(FlexContainer, Object.assign({ disableGutters: true }, { children: _jsx(AppRoutes, {}) })), _jsx(PoweredBy, {}), _jsx(Initializer, {})] }));
23
+ };
24
+ const AppRoutes = () => {
25
+ const element = useRoutes([
26
+ {
27
+ path: '/',
28
+ element: _jsx(MainPage, {}),
29
+ },
30
+ {
31
+ path: navigationRoutes.settings,
32
+ element: _jsx(SettingsPage, {}),
33
+ },
34
+ {
35
+ path: navigationRoutes.fromToken,
36
+ element: _jsx(SelectTokenPage, { formType: "from" }),
37
+ },
38
+ {
39
+ path: navigationRoutes.toToken,
40
+ element: _jsx(SelectTokenPage, { formType: "to" }),
41
+ },
42
+ {
43
+ path: navigationRoutes.swapRoutes,
44
+ element: _jsx(SwapRoutesPage, {}),
45
+ },
46
+ {
47
+ path: navigationRoutes.swapHistory,
48
+ element: _jsx(SwapHistoryPage, {}),
49
+ },
50
+ {
51
+ path: `${navigationRoutes.swapHistory}/${navigationRoutes.swapDetails}`,
52
+ element: _jsx(SwapDetailsPage, {}),
53
+ },
54
+ ...[
55
+ navigationRoutes.selectWallet,
56
+ `${navigationRoutes.swapExecution}/${navigationRoutes.selectWallet}`,
57
+ `${navigationRoutes.swapRoutes}/${navigationRoutes.swapExecution}/${navigationRoutes.selectWallet}`,
58
+ ].map((path) => ({
59
+ path,
60
+ element: _jsx(SelectWalletPage, {}),
61
+ })),
62
+ ...[
63
+ navigationRoutes.swapExecution,
64
+ `${navigationRoutes.swapRoutes}/${navigationRoutes.swapExecution}`,
65
+ ].map((path) => ({
66
+ path,
67
+ element: _jsx(SwapPage, {}),
68
+ })),
69
+ {
70
+ path: '*',
71
+ element: _jsx(NotFound, {}),
72
+ },
73
+ ]);
74
+ return element;
23
75
  };
@@ -20,22 +20,15 @@ export const GasSufficiencyMessage = (_a) => {
20
20
  var { route } = _a, props = __rest(_a, ["route"]);
21
21
  const { t } = useTranslation();
22
22
  const { insufficientFunds, insufficientGas } = useGasSufficiency(route);
23
- if (!insufficientFunds || !insufficientGas.length) {
23
+ if (!insufficientFunds && !insufficientGas.length) {
24
24
  return null;
25
25
  }
26
- let title;
27
- let message;
28
- if (insufficientFunds) {
29
- message = t(`swap.warning.message.insufficientFunds`);
30
- }
31
- else if (insufficientGas.length) {
32
- title = t(`swap.warning.title.insufficientGas`);
33
- message = t(`swap.warning.message.insufficientGas`);
34
- }
35
26
  return (_jsxs(MessageCard, Object.assign({}, props, { children: [_jsx(WarningIcon, { sx: {
36
27
  marginTop: 2,
37
28
  marginLeft: 2,
38
- } }), _jsxs(Box, { children: [title ? _jsx(CardTitle, { children: title }) : null, _jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: !insufficientFunds && insufficientGas.length ? 0 : 2, pt: title ? 1 : 2 }, { children: message })), !insufficientFunds && insufficientGas.length
29
+ } }), _jsxs(Box, { children: [insufficientGas.length ? (_jsx(CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length ? 0 : 2, pt: insufficientGas.length ? 1 : 2 }, { children: insufficientFunds
30
+ ? t(`swap.warning.message.insufficientFunds`)
31
+ : null }))) : null, insufficientGas.length ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, insufficientGas.length
39
32
  ? insufficientGas.map((item, index) => {
40
33
  var _a, _b;
41
34
  return (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length - 1 === index ? 2 : 0, pt: 0.5 }, { children: t(`swap.tokenOnChainAmount`, {
@@ -4,7 +4,7 @@ import { Box, IconButton, Typography } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
6
6
  import { useWallet } from '../../providers/WalletProvider';
7
- import { navigationRoutes } from '../../utils';
7
+ import { navigationRoutes, navigationRoutesValues } from '../../utils';
8
8
  import { HeaderAppBar } from './Header.style';
9
9
  import { useHeaderActionStore } from './useHeaderActionStore';
10
10
  const backButtonRoutes = [
@@ -14,20 +14,22 @@ const backButtonRoutes = [
14
14
  navigationRoutes.fromToken,
15
15
  navigationRoutes.toToken,
16
16
  navigationRoutes.swapRoutes,
17
- navigationRoutes.swap,
17
+ navigationRoutes.swapExecution,
18
18
  navigationRoutes.swapDetails,
19
19
  ];
20
20
  export const NavigationHeader = () => {
21
21
  const { t } = useTranslation();
22
- const { pathname } = useLocation();
23
22
  const navigate = useNavigate();
24
23
  const { account } = useWallet();
25
- const { path: actionPath, element } = useHeaderActionStore();
24
+ const { element } = useHeaderActionStore();
25
+ const { pathname } = useLocation();
26
+ const path = pathname.substring(pathname.lastIndexOf('/') + 1);
27
+ const hasPath = navigationRoutesValues.includes(path);
26
28
  const handleBack = () => {
27
29
  navigate(-1);
28
30
  };
29
31
  const handleHeaderTitle = () => {
30
- switch (pathname) {
32
+ switch (path) {
31
33
  case navigationRoutes.selectWallet:
32
34
  return t(`header.selectWallet`);
33
35
  case navigationRoutes.settings:
@@ -40,7 +42,7 @@ export const NavigationHeader = () => {
40
42
  return t(`header.to`);
41
43
  case navigationRoutes.swapRoutes:
42
44
  return t(`header.routes`);
43
- case navigationRoutes.swap:
45
+ case navigationRoutes.swapExecution:
44
46
  return t(`header.swap`);
45
47
  case navigationRoutes.swapDetails:
46
48
  return t(`header.swapDetails`);
@@ -48,5 +50,5 @@ export const NavigationHeader = () => {
48
50
  return t(`header.swap`);
49
51
  }
50
52
  };
51
- return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(pathname) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: handleBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: pathname === '/' ? 24 : 18, align: pathname === '/' ? 'left' : 'center', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory) }, { children: _jsx(HistoryIcon, {}) }))) : null, _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(navigationRoutes.settings) }, { children: _jsx(SettingsIcon, {}) }))] }) }), _jsx(Route, { path: actionPath !== null && actionPath !== void 0 ? actionPath : '*', element: element || _jsx(Box, { width: 28, height: 40 }) })] })] })));
53
+ return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: handleBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory) }, { children: _jsx(HistoryIcon, {}) }))) : null, _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(navigationRoutes.settings) }, { children: _jsx(SettingsIcon, {}) }))] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] })));
52
54
  };
@@ -1,9 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  export interface HeaderActionState {
3
- path?: string | null;
4
3
  element?: React.ReactNode | null;
5
4
  }
6
5
  export interface HeaderActionStore extends HeaderActionState {
7
- setAction(path?: string, element?: React.ReactNode | null): () => void;
6
+ setAction(element?: React.ReactNode | null): () => void;
8
7
  removeAction(): void;
9
8
  }
@@ -3,4 +3,4 @@ import { HeaderActionStore } from './types';
3
3
  export declare const useHeaderActionStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<HeaderActionStore>, "setState"> & {
4
4
  setState(nextStateOrUpdater: HeaderActionStore | Partial<HeaderActionStore> | ((state: import("immer/dist/internal").WritableDraft<HeaderActionStore>) => void), shouldReplace?: boolean | undefined): void;
5
5
  }>;
6
- export declare const useSetHeaderAction: () => (path?: string | undefined, element?: import("react").ReactNode) => () => void;
6
+ export declare const useSetHeaderAction: () => (element?: import("react").ReactNode) => () => void;
@@ -2,16 +2,14 @@
2
2
  import create from 'zustand';
3
3
  import { immer } from 'zustand/middleware/immer';
4
4
  export const useHeaderActionStore = create()(immer((set, get) => ({
5
- setAction: (path, element) => {
5
+ setAction: (element) => {
6
6
  set((state) => {
7
- state.path = path;
8
7
  state.element = element;
9
8
  });
10
9
  return get().removeAction;
11
10
  },
12
11
  removeAction: () => {
13
12
  set((state) => {
14
- state.path = null;
15
13
  state.element = null;
16
14
  });
17
15
  },
@@ -16,7 +16,7 @@ export const SwapInProgress = (props) => {
16
16
  const { account } = useWallet();
17
17
  const executingRoutes = useExecutingRoutes(account.address);
18
18
  const handleCardClick = useCallback((routeId) => {
19
- navigate(navigationRoutes.swap, { state: { routeId } });
19
+ navigate(navigationRoutes.swapExecution, { state: { routeId } });
20
20
  }, [navigate]);
21
21
  if (!(executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length)) {
22
22
  return null;
package/config/theme.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { dialogActionsClasses } from '@mui/material/DialogActions';
2
- import { alpha, createTheme as createMuiTheme, darken, lighten, } from '@mui/material/styles';
2
+ import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, lighten, } from '@mui/material/styles';
3
+ import { dark, light } from '@mui/material/styles/createPalette';
3
4
  const palette = {
4
5
  primary: {
5
6
  main: '#3F49E1',
@@ -24,8 +25,12 @@ const palette = {
24
25
  main: '#297EFF',
25
26
  },
26
27
  };
28
+ const shape = {
29
+ borderRadius: 12,
30
+ borderRadiusSecondary: 6,
31
+ };
27
32
  export const createTheme = (mode, theme = {}) => {
28
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
33
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
29
34
  return createMuiTheme({
30
35
  typography: Object.assign({ fontFamily: 'Inter var, Inter, sans-serif' }, theme.typography),
31
36
  palette: Object.assign(Object.assign(Object.assign({ mode }, palette), { primary: {
@@ -57,7 +62,7 @@ export const createTheme = (mode, theme = {}) => {
57
62
  paper: '#212121',
58
63
  },
59
64
  })),
60
- shape: Object.assign({ borderRadius: 12, borderRadiusSecondary: 6 }, theme.shape),
65
+ shape: Object.assign(Object.assign({}, shape), theme.shape),
61
66
  breakpoints: {
62
67
  values: {
63
68
  xs: 0,
@@ -96,26 +101,35 @@ export const createTheme = (mode, theme = {}) => {
96
101
  },
97
102
  }
98
103
  : {})), { root: {
99
- borderRadius: (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary,
104
+ borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
100
105
  textTransform: 'none',
101
106
  fontSize: '1rem',
102
107
  padding: '10px 16px',
103
108
  [`.${dialogActionsClasses.root} &`]: {
104
109
  padding: '6px 12px',
105
110
  },
106
- '&.Mui-disabled': {
111
+ '&.Mui-disabled, &.Mui-disabled:hover': {
107
112
  color: mode === 'light'
108
113
  ? 'rgb(0 0 0 / 70%)'
109
114
  : 'rgb(255 255 255 / 70%)',
110
115
  cursor: 'not-allowed',
111
116
  pointerEvents: 'auto',
112
117
  },
118
+ }, contained: {
119
+ '&:hover': {
120
+ color: getContrastRatio(palette.primary.main, dark.text.primary) >= 3
121
+ ? dark.text.primary
122
+ : light.text.primary,
123
+ },
113
124
  } }),
114
125
  },
115
126
  MuiIconButton: {
116
127
  styleOverrides: {
117
128
  root: {
118
129
  color: 'inherit',
130
+ '&:hover': {
131
+ color: 'inherit',
132
+ },
119
133
  },
120
134
  },
121
135
  },
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.11.0";
2
+ export declare const version = "1.11.3";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.11.0';
2
+ export const version = '1.11.3';
@@ -82,7 +82,7 @@ export const useGasSufficiency = (route) => {
82
82
  return false;
83
83
  }
84
84
  const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
85
- return Big(fromAmount).gte(balance);
85
+ return Big(fromAmount).gt(balance);
86
86
  }, [account.isActive, fromAmount, fromChainTokenBalances, fromToken]);
87
87
  return {
88
88
  insufficientGas,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.11.0",
3
+ "version": "1.11.3",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "sideEffects": false,
6
6
  "main": "./index.js",
@@ -21,7 +21,7 @@ export const MainSwapButton = () => {
21
21
  const handleClick = () => __awaiter(void 0, void 0, void 0, function* () {
22
22
  if (currentRoute) {
23
23
  setExecutableRoute(currentRoute);
24
- navigate(navigationRoutes.swap, {
24
+ navigate(navigationRoutes.swapExecution, {
25
25
  state: { routeId: currentRoute.id },
26
26
  });
27
27
  }
@@ -32,5 +32,5 @@ export const SwapRoutes = (props) => {
32
32
  borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
33
33
  ? 1
34
34
  : 0,
35
- } }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : isLoading || isFetching || !currentRoute ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })), !isFetching ? (_jsx(GasSufficiencyMessage, Object.assign({ route: currentRoute }, props))) : null] }));
35
+ } }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : isLoading || isFetching || !currentRoute ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })), _jsx(GasSufficiencyMessage, Object.assign({ route: !isFetching ? currentRoute : undefined }, props))] }));
36
36
  };
@@ -20,7 +20,6 @@ import { useSetHeaderAction } from '../../components/Header';
20
20
  import { Step } from '../../components/Step';
21
21
  import { StepDivider } from '../../components/StepDivider';
22
22
  import { useRouteStore } from '../../stores';
23
- import { navigationRoutes } from '../../utils';
24
23
  import { Container } from './SwapDetailsPage.style';
25
24
  export const SwapDetailsPage = () => {
26
25
  var _a, _b;
@@ -44,7 +43,7 @@ export const SwapDetailsPage = () => {
44
43
  yield navigator.clipboard.writeText((_c = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id) !== null && _c !== void 0 ? _c : '');
45
44
  });
46
45
  useEffect(() => {
47
- return setHeaderAction(navigationRoutes.swapDetails, _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
46
+ return setHeaderAction(_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
48
47
  }, [setHeaderAction, toggleDialog]);
49
48
  const startedAt = new Date((_b = (_a = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process[0].startedAt) !== null && _b !== void 0 ? _b : 0);
50
49
  return (_jsxs(Container, { children: [_jsxs(Box, Object.assign({ sx: {
@@ -41,5 +41,5 @@ export const SwapPage = () => {
41
41
  return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
42
42
  ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
43
43
  ? Object.assign(Object.assign({}, step.action.toToken), { amount: (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
44
- }), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { onClick: handleSwapClick, text: getSwapButtonText() }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
44
+ }), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
45
45
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect } from 'react';
3
- import { useNavigate } from 'react-router-dom';
3
+ import { useLocation, useNavigate } from 'react-router-dom';
4
4
  import { useSetHeaderAction } from '../../components/Header';
5
5
  import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
6
6
  import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
@@ -10,25 +10,26 @@ import { navigationRoutes } from '../../utils';
10
10
  import { Stack } from './SwapRoutesPage.style';
11
11
  export const SwapRoutesPage = () => {
12
12
  const navigate = useNavigate();
13
+ const { pathname } = useLocation();
13
14
  const setHeaderAction = useSetHeaderAction();
14
15
  const { routes: swapRoutes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
15
16
  const setExecutableRoute = useSetExecutableRoute();
16
17
  const handleRouteClick = (route) => {
17
18
  setExecutableRoute(route);
18
- navigate(navigationRoutes.swap, {
19
+ navigate(navigationRoutes.swapExecution, {
19
20
  state: { routeId: route.id },
20
21
  });
21
22
  };
22
23
  useEffect(() => {
23
24
  if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching) {
24
- navigate(navigationRoutes.home);
25
+ navigate(pathname.substring(0, pathname.lastIndexOf('/')));
25
26
  }
26
27
  // redirect to the home page if no routes are found on page reload
27
28
  // eslint-disable-next-line react-hooks/exhaustive-deps
28
29
  }, []);
29
30
  useEffect(() => {
30
- return setHeaderAction(navigationRoutes.swapRoutes, _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
31
+ return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
31
32
  }, [dataUpdatedAt, isFetching, refetch, refetchTime, setHeaderAction]);
32
33
  const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && isFetched;
33
- return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, { dense: true })) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, { dense: true }, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route) }, route.id)))) })));
34
+ return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route) }, route.id)))) })));
34
35
  };
@@ -5,7 +5,7 @@ export declare const navigationRoutes: {
5
5
  fromToken: string;
6
6
  toToken: string;
7
7
  swapRoutes: string;
8
- swap: string;
8
+ swapExecution: string;
9
9
  swapHistory: string;
10
10
  swapDetails: string;
11
11
  };
@@ -1,12 +1,12 @@
1
1
  export const navigationRoutes = {
2
2
  home: '/',
3
- selectWallet: '/select-wallet',
4
- settings: '/settings',
5
- fromToken: '/select-from-token',
6
- toToken: '/select-to-token',
7
- swapRoutes: '/swap-routes',
8
- swap: '/swap',
9
- swapHistory: '/swap-history',
10
- swapDetails: '/swap-details',
3
+ selectWallet: 'select-wallet',
4
+ settings: 'settings',
5
+ fromToken: 'select-from-token',
6
+ toToken: 'select-to-token',
7
+ swapRoutes: 'swap-routes',
8
+ swapExecution: 'swap-execution',
9
+ swapHistory: 'swap-history',
10
+ swapDetails: 'swap-details',
11
11
  };
12
12
  export const navigationRoutesValues = Object.values(navigationRoutes);