@lifi/widget 1.11.2 → 1.12.0
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/components/Header/Header.js +3 -1
- package/components/NotFound.js +2 -1
- package/components/SwapButton/SwapButton.js +4 -0
- package/components/SwapRouteCard/SwapRouteCard.js +2 -2
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -2
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +7 -8
- package/config/theme.js +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/i18n/en/translation.json +8 -4
- package/i18n/index.d.ts +4 -0
- package/package.json +5 -5
- package/pages/MainPage/SwapRoutes.js +3 -3
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
- package/pages/SwapHistoryPage/SwapHistoryPage.js +19 -3
- package/pages/SwapPage/SwapPage.js +1 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +3 -3
- package/stores/route/types.d.ts +1 -0
- package/stores/route/useRouteStore.js +3 -0
|
@@ -9,10 +9,12 @@ const stickyHeaderRoutes = [
|
|
|
9
9
|
navigationRoutes.selectWallet,
|
|
10
10
|
navigationRoutes.settings,
|
|
11
11
|
navigationRoutes.swapRoutes,
|
|
12
|
+
navigationRoutes.swapHistory,
|
|
13
|
+
navigationRoutes.swapDetails,
|
|
12
14
|
];
|
|
13
15
|
const HeaderContainer = ({ children }) => {
|
|
14
16
|
const { pathname } = useLocation();
|
|
15
|
-
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.includes(
|
|
17
|
+
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
16
18
|
};
|
|
17
19
|
export const Header = () => {
|
|
18
20
|
const { walletManagement } = useWidgetConfig();
|
package/components/NotFound.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Block as BlockIcon } from '@mui/icons-material';
|
|
2
3
|
import { Box, Typography } from '@mui/material';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
export const NotFound = () => {
|
|
@@ -10,5 +11,5 @@ export const NotFound = () => {
|
|
|
10
11
|
flexDirection: 'column',
|
|
11
12
|
flex: 1,
|
|
12
13
|
padding: 3,
|
|
13
|
-
} }, { children: [_jsx(Typography, Object.assign({
|
|
14
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(BlockIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('tooltip.notFound.title') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('tooltip.notFound.text') }))] })));
|
|
14
15
|
};
|
|
@@ -52,6 +52,9 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
52
52
|
if (!isCurrentChainMatch) {
|
|
53
53
|
return t(`button.switchChain`);
|
|
54
54
|
}
|
|
55
|
+
if (!currentRoute) {
|
|
56
|
+
return t(`button.swap`);
|
|
57
|
+
}
|
|
55
58
|
return text || t(`button.reviewSwap`);
|
|
56
59
|
}
|
|
57
60
|
return t(`button.connectWallet`);
|
|
@@ -59,5 +62,6 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
59
62
|
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
60
63
|
// loading={isLoading || isFetching}
|
|
61
64
|
disabled: (insufficientFunds || !!insufficientGas.length || loading) &&
|
|
65
|
+
currentRoute &&
|
|
62
66
|
isCurrentChainMatch, fullWidth: true }, { children: getButtonText() })));
|
|
63
67
|
};
|
|
@@ -32,7 +32,7 @@ export const SwapRouteCard = (_a) => {
|
|
|
32
32
|
: null, _jsxs(Box, Object.assign({ sx: {
|
|
33
33
|
display: 'flex',
|
|
34
34
|
justifyContent: 'space-between',
|
|
35
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500" }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary" }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end" }, { children: ["~", (route.steps
|
|
35
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500", lineHeight: 1, pt: 0.25 }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", lineHeight: 1, mt: 0.5 }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end", lineHeight: 1, pt: 0.25 }, { children: ["~", (route.steps
|
|
36
36
|
.map((step) => step.estimate.executionDuration)
|
|
37
|
-
.reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end" }, { children: t(`swap.minutes`) }))] })] }))] })));
|
|
37
|
+
.reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end", lineHeight: 1, mt: 0.5 }, { children: t(`swap.minutes`) }))] })] }))] })));
|
|
38
38
|
};
|
|
@@ -20,9 +20,9 @@ export const SwapRouteCardSkeleton = (_a) => {
|
|
|
20
20
|
} }, { children: [_jsx(Box, Object.assign({ mr: 2 }, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) })), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] })), _jsx(Box, Object.assign({ ml: 6 }, { children: _jsx(Skeleton, { variant: "text", width: 102, height: 16, sx: { borderRadius: 0.5 } }) }))] })), _jsxs(Box, Object.assign({ sx: {
|
|
21
21
|
display: 'flex',
|
|
22
22
|
justifyContent: 'space-between',
|
|
23
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height:
|
|
23
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height: 20 }), _jsx(Skeleton, { variant: "text", width: 52, height: 16 })] }), _jsxs(Box, Object.assign({ sx: {
|
|
24
24
|
display: 'flex',
|
|
25
25
|
alignItems: 'flex-end',
|
|
26
26
|
flexDirection: 'column',
|
|
27
|
-
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height:
|
|
27
|
+
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 16 })] }))] }))] })));
|
|
28
28
|
};
|
|
@@ -13,15 +13,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Route as RouteIcon } from '@mui/icons-material';
|
|
14
14
|
import { Box, Typography } from '@mui/material';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import { Card } from '../Card';
|
|
17
16
|
export const SwapRouteNotFoundCard = (_a) => {
|
|
18
17
|
var { dense } = _a, other = __rest(_a, ["dense"]);
|
|
19
18
|
const { t } = useTranslation();
|
|
20
|
-
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
return (_jsxs(Box, Object.assign({ sx: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
flex: 1,
|
|
25
|
+
}, py: 2.375 }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(RouteIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.routeNotFound') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.routeNotFound') }))] })));
|
|
27
26
|
};
|
package/config/theme.js
CHANGED
|
@@ -108,7 +108,7 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
108
108
|
[`.${dialogActionsClasses.root} &`]: {
|
|
109
109
|
padding: '6px 12px',
|
|
110
110
|
},
|
|
111
|
-
'&.Mui-disabled': {
|
|
111
|
+
'&.Mui-disabled, &.Mui-disabled:hover': {
|
|
112
112
|
color: mode === 'light'
|
|
113
113
|
? 'rgb(0 0 0 / 70%)'
|
|
114
114
|
: 'rgb(255 255 255 / 70%)',
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.12.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.12.0';
|
package/i18n/en/translation.json
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"button": {
|
|
15
15
|
"connectWallet": "Connect wallet",
|
|
16
16
|
"switchChain": "Switch chain",
|
|
17
|
+
"swap": "Swap",
|
|
17
18
|
"reviewSwap": "Review swap",
|
|
18
19
|
"startSwap": "Start swap",
|
|
19
20
|
"restartSwap": "Restart swap",
|
|
@@ -78,16 +79,19 @@
|
|
|
78
79
|
},
|
|
79
80
|
"info": {
|
|
80
81
|
"title": {
|
|
81
|
-
"routeNotFound": "No routes available"
|
|
82
|
+
"routeNotFound": "No routes available",
|
|
83
|
+
"emptySwapHistory": "No recent swaps"
|
|
82
84
|
},
|
|
83
85
|
"message": {
|
|
84
|
-
"routeNotFound": "Try another token combination."
|
|
86
|
+
"routeNotFound": "Try another token combination.",
|
|
87
|
+
"emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data."
|
|
85
88
|
}
|
|
86
89
|
},
|
|
87
90
|
"warning": {
|
|
88
91
|
"title": {
|
|
89
92
|
"insufficientGas": "Insufficient gas",
|
|
90
|
-
"deleteSwap": "Delete this swap?"
|
|
93
|
+
"deleteSwap": "Delete this swap?",
|
|
94
|
+
"deleteSwapHistory": "Delete swap history?"
|
|
91
95
|
},
|
|
92
96
|
"message": {
|
|
93
97
|
"insufficientFunds": "You don't have enough funds to execute the swap.",
|
|
@@ -161,7 +165,7 @@
|
|
|
161
165
|
},
|
|
162
166
|
"tooltip": {
|
|
163
167
|
"notFound": {
|
|
164
|
-
"title": "
|
|
168
|
+
"title": "404",
|
|
165
169
|
"text": "We couldn't find this page."
|
|
166
170
|
},
|
|
167
171
|
"progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click this circle to update manually."
|
package/i18n/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const resources: {
|
|
|
17
17
|
button: {
|
|
18
18
|
connectWallet: string;
|
|
19
19
|
switchChain: string;
|
|
20
|
+
swap: string;
|
|
20
21
|
reviewSwap: string;
|
|
21
22
|
startSwap: string;
|
|
22
23
|
restartSwap: string;
|
|
@@ -82,15 +83,18 @@ export declare const resources: {
|
|
|
82
83
|
info: {
|
|
83
84
|
title: {
|
|
84
85
|
routeNotFound: string;
|
|
86
|
+
emptySwapHistory: string;
|
|
85
87
|
};
|
|
86
88
|
message: {
|
|
87
89
|
routeNotFound: string;
|
|
90
|
+
emptySwapHistory: string;
|
|
88
91
|
};
|
|
89
92
|
};
|
|
90
93
|
warning: {
|
|
91
94
|
title: {
|
|
92
95
|
insufficientGas: string;
|
|
93
96
|
deleteSwap: string;
|
|
97
|
+
deleteSwapHistory: string;
|
|
94
98
|
};
|
|
95
99
|
message: {
|
|
96
100
|
insufficientFunds: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
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",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"@mui/icons-material": "^5.8.4",
|
|
47
47
|
"@mui/lab": "^5.0.0-alpha.92",
|
|
48
48
|
"@mui/material": "^5.9.2",
|
|
49
|
-
"@sentry/integrations": "^7.
|
|
50
|
-
"@sentry/react": "^7.
|
|
51
|
-
"@sentry/tracing": "^7.
|
|
49
|
+
"@sentry/integrations": "^7.8.0",
|
|
50
|
+
"@sentry/react": "^7.8.0",
|
|
51
|
+
"@sentry/tracing": "^7.8.0",
|
|
52
52
|
"@tanstack/react-query": "^4.0.10",
|
|
53
53
|
"big.js": "^6.2.1",
|
|
54
54
|
"i18next": "^21.8.14",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react": "^18.2.0",
|
|
57
57
|
"react-dom": "^18.2.0",
|
|
58
58
|
"react-hook-form": "^7.33.1",
|
|
59
|
-
"react-i18next": "^11.18.
|
|
59
|
+
"react-i18next": "^11.18.3",
|
|
60
60
|
"react-resize-detector": "^7.1.2",
|
|
61
61
|
"react-router-dom": "^6.3.0",
|
|
62
62
|
"react-timer-hook": "^3.0.5",
|
|
@@ -23,8 +23,8 @@ export const SwapRoutes = (props) => {
|
|
|
23
23
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
const routeNotFound = !currentRoute &&
|
|
27
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
26
|
+
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
28
28
|
position: 'absolute',
|
|
29
29
|
top: 8,
|
|
30
30
|
right: 8,
|
|
@@ -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:
|
|
35
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", 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
|
};
|
|
@@ -10,5 +10,5 @@ export const SwapHistoryEmpty = () => {
|
|
|
10
10
|
flexDirection: 'column',
|
|
11
11
|
alignItems: 'center',
|
|
12
12
|
justifyContent: 'center',
|
|
13
|
-
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(HistoryIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children:
|
|
13
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(HistoryIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.emptySwapHistory') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.emptySwapHistory') }))] })));
|
|
14
14
|
};
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DeleteOutline as DeleteIcon } from '@mui/icons-material';
|
|
3
|
+
import { Button, Container, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, Stack, } from '@mui/material';
|
|
4
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { Dialog } from '../../components/Dialog';
|
|
7
|
+
import { useSetHeaderAction } from '../../components/Header';
|
|
3
8
|
import { useWallet } from '../../providers/WalletProvider';
|
|
9
|
+
import { useRouteStore } from '../../stores';
|
|
4
10
|
import { useSwapHistory } from '../../stores/route';
|
|
5
11
|
import { SwapHistoryEmpty } from './SwapHistoryEmpty';
|
|
6
12
|
import { SwapHistoryItem } from './SwapHistoryItem';
|
|
7
13
|
export const SwapHistoryPage = () => {
|
|
14
|
+
const { t } = useTranslation();
|
|
8
15
|
const { account } = useWallet();
|
|
9
16
|
const swaps = useSwapHistory(account.address);
|
|
17
|
+
const deleteRoutes = useRouteStore((store) => store.deleteRoutes);
|
|
18
|
+
const setHeaderAction = useSetHeaderAction();
|
|
19
|
+
const [open, setOpen] = useState(false);
|
|
20
|
+
const toggleDialog = useCallback(() => {
|
|
21
|
+
setOpen((open) => !open);
|
|
22
|
+
}, []);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
return setHeaderAction(_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
|
|
25
|
+
}, [setHeaderAction, toggleDialog]);
|
|
10
26
|
if (!swaps.length) {
|
|
11
27
|
return _jsx(SwapHistoryEmpty, {});
|
|
12
28
|
}
|
|
13
|
-
return (
|
|
29
|
+
return (_jsxs(Container, { children: [_jsx(Stack, Object.assign({ spacing: 2, mt: 1 }, { children: swaps.length ? (swaps.map(({ route }) => (_jsx(SwapHistoryItem, { route: route }, route.id)))) : (_jsx(SwapHistoryEmpty, {})) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwapHistory') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: deleteRoutes, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
|
|
14
30
|
};
|
|
@@ -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,
|
|
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
|
};
|
|
@@ -28,8 +28,8 @@ export const SwapRoutesPage = () => {
|
|
|
28
28
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
29
|
}, []);
|
|
30
30
|
useEffect(() => {
|
|
31
|
-
return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
|
|
31
|
+
return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
|
|
32
32
|
}, [dataUpdatedAt, isFetching, refetch, refetchTime, setHeaderAction]);
|
|
33
|
-
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) &&
|
|
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
|
|
33
|
+
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching;
|
|
34
|
+
return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1 }, { 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) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route) }, route.id)))) })));
|
|
35
35
|
};
|
package/stores/route/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface RouteExecutionStore {
|
|
|
5
5
|
updateRoute: (route: Route) => void;
|
|
6
6
|
restartRoute: (routeId: string) => void;
|
|
7
7
|
deleteRoute: (routeId: string) => void;
|
|
8
|
+
deleteRoutes: () => void;
|
|
8
9
|
}
|
|
9
10
|
export declare type RouteExecutionStatus = 'error' | 'idle' | 'loading' | 'success';
|
|
10
11
|
export interface RouteExecution {
|
|
@@ -54,6 +54,9 @@ export const useRouteStore = create()(persist(immer((set) => ({
|
|
|
54
54
|
delete state.routes[routeId];
|
|
55
55
|
}
|
|
56
56
|
}),
|
|
57
|
+
deleteRoutes: () => set((state) => {
|
|
58
|
+
state.routes = {};
|
|
59
|
+
}),
|
|
57
60
|
})), {
|
|
58
61
|
name: 'li.fi-widget-routes',
|
|
59
62
|
partialize: (state) => ({ routes: state.routes }),
|