@rango-dev/widget-embedded 0.21.1-next.3 → 0.21.1-next.4

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.
Files changed (32) hide show
  1. package/dist/components/HistoryGroupedList/HistoryGroupedList.d.ts +4 -0
  2. package/dist/components/HistoryGroupedList/HistoryGroupedList.d.ts.map +1 -0
  3. package/dist/components/HistoryGroupedList/HistoryGroupedList.helpers.d.ts +2 -0
  4. package/dist/components/HistoryGroupedList/HistoryGroupedList.helpers.d.ts.map +1 -0
  5. package/dist/components/{SwapsGroup/SwapsGroup.styles.d.ts → HistoryGroupedList/HistoryGroupedList.styles.d.ts} +162 -1
  6. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts.map +1 -0
  7. package/dist/components/{SwapsGroup/SwapsGroup.types.d.ts → HistoryGroupedList/HistoryGroupedList.types.d.ts} +5 -4
  8. package/dist/components/HistoryGroupedList/HistoryGroupedList.types.d.ts.map +1 -0
  9. package/dist/components/HistoryGroupedList/index.d.ts +2 -0
  10. package/dist/components/HistoryGroupedList/index.d.ts.map +1 -0
  11. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  12. package/dist/index.js +2 -2
  13. package/dist/index.js.map +4 -4
  14. package/dist/utils/date.d.ts +1 -1
  15. package/dist/utils/date.d.ts.map +1 -1
  16. package/package.json +3 -3
  17. package/src/components/HistoryGroupedList/HistoryGroupedList.helpers.ts +17 -0
  18. package/src/components/{SwapsGroup/SwapsGroup.styles.ts → HistoryGroupedList/HistoryGroupedList.styles.ts} +9 -0
  19. package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +168 -0
  20. package/src/components/{SwapsGroup/SwapsGroup.types.ts → HistoryGroupedList/HistoryGroupedList.types.ts} +4 -3
  21. package/src/components/HistoryGroupedList/index.ts +1 -0
  22. package/src/components/TokenList/TokenList.tsx +4 -24
  23. package/src/pages/HistoryPage.tsx +6 -6
  24. package/src/utils/date.ts +9 -2
  25. package/dist/components/SwapsGroup/SwapsGroup.d.ts +0 -4
  26. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +0 -1
  27. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +0 -1
  28. package/dist/components/SwapsGroup/SwapsGroup.types.d.ts.map +0 -1
  29. package/dist/components/SwapsGroup/index.d.ts +0 -2
  30. package/dist/components/SwapsGroup/index.d.ts.map +0 -1
  31. package/src/components/SwapsGroup/SwapsGroup.tsx +0 -141
  32. package/src/components/SwapsGroup/index.ts +0 -1
@@ -1,3 +1,3 @@
1
- import type { GroupBy } from '../components/SwapsGroup/SwapsGroup.types';
1
+ import type { GroupBy } from '../components/HistoryGroupedList/HistoryGroupedList.types';
2
2
  export declare const groupSwapsByDate: GroupBy;
3
3
  //# sourceMappingURL=date.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAMzE,eAAO,MAAM,gBAAgB,EAAE,OAmE9B,CAAC"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2DAA2D,CAAC;AAMzF,eAAO,MAAM,gBAAgB,EAAE,OA0E9B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.21.1-next.3",
3
+ "version": "0.21.1-next.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  "@rango-dev/queue-manager-core": "^0.25.0",
26
26
  "@rango-dev/queue-manager-rango-preset": "^0.26.0",
27
27
  "@rango-dev/queue-manager-react": "^0.25.0",
28
- "@rango-dev/ui": "^0.27.1-next.1",
28
+ "@rango-dev/ui": "^0.27.1-next.3",
29
29
  "@rango-dev/wallets-react": "^0.12.0",
30
30
  "@rango-dev/wallets-shared": "^0.26.0",
31
31
  "bignumber.js": "^9.1.1",
@@ -47,4 +47,4 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  }
50
- }
50
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * The calculateGroupsSoFar Slices the total groups into the groups which contain the items so far.
3
+ * For example, if you have [10, 10, 10, 10] groups in total,
4
+ * slicing them to 23 will result in [10, 10, 3] :
5
+ * https://virtuoso.dev/grouped-with-load-on-demand/
6
+ */
7
+ export function calculateGroupsSoFar(totalGroups: number[], count: number) {
8
+ const groups: number[] = [];
9
+ let index = 0;
10
+ do {
11
+ const group = totalGroups[index];
12
+ groups.push(Math.min(group, count));
13
+ count -= group;
14
+ index++;
15
+ } while (count > 0 && index <= totalGroups.length);
16
+ return groups;
17
+ }
@@ -2,10 +2,19 @@ import { css, darkTheme, styled } from '@rango-dev/ui';
2
2
 
3
3
  export const groupStyles = css();
4
4
 
5
+ export const SwapItemContainer = styled('div', {
6
+ display: 'flex',
7
+ justifyContent: 'center',
8
+ alignItems: 'center',
9
+ padding: '$5',
10
+ });
11
+
5
12
  export const Group = styled('div', {
6
13
  width: '100%',
7
14
  display: 'flex',
8
15
  flexDirection: 'column',
16
+ backgroundColor: '$background',
17
+ padding: '$10 $5 0 $5',
9
18
  [`& .${groupStyles}`]: {
10
19
  $$color: '$colors$neutral600',
11
20
  [`.${darkTheme} &`]: {
@@ -0,0 +1,168 @@
1
+ import type { PropTypes } from './HistoryGroupedList.types';
2
+
3
+ import { i18n } from '@lingui/core';
4
+ import {
5
+ Divider,
6
+ GroupedVirtualizedList,
7
+ SwapListItem,
8
+ Typography,
9
+ } from '@rango-dev/ui';
10
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
11
+
12
+ import {
13
+ TOKEN_AMOUNT_MAX_DECIMALS,
14
+ TOKEN_AMOUNT_MIN_DECIMALS,
15
+ } from '../../constants/routing';
16
+ import { getContainer } from '../../utils/common';
17
+ import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
18
+
19
+ import { calculateGroupsSoFar } from './HistoryGroupedList.helpers';
20
+ import {
21
+ Group,
22
+ groupStyles,
23
+ SwapItemContainer,
24
+ SwapList,
25
+ Time,
26
+ } from './HistoryGroupedList.styles';
27
+
28
+ const ITEMS_PER_PAGE = 10;
29
+
30
+ export function HistoryGroupedList(props: PropTypes) {
31
+ const { list, onSwapClick, groupBy, isLoading } = props;
32
+ const [currentGroupCounts, setCurrentGroupCounts] = useState<number[]>([]);
33
+ const loadedItems = useRef(0);
34
+ const { swaps, groupCounts, groups } = groupBy(list);
35
+
36
+ const calculateGroups = useCallback(calculateGroupsSoFar, []);
37
+
38
+ const loadMore = useCallback(() => {
39
+ const remainedItems = list.length - loadedItems.current;
40
+ if (remainedItems) {
41
+ loadedItems.current += Math.min(remainedItems, ITEMS_PER_PAGE);
42
+ setCurrentGroupCounts(calculateGroups(groupCounts, loadedItems.current));
43
+ }
44
+ }, [list.length]);
45
+
46
+ useEffect(() => {
47
+ if (!isLoading) {
48
+ loadMore();
49
+ }
50
+ }, [isLoading, loadMore]);
51
+
52
+ if (isLoading) {
53
+ const swaps = [{}, {}];
54
+
55
+ const loadingGroups = [
56
+ {
57
+ title: i18n.t('Today'),
58
+ swaps,
59
+ },
60
+ {
61
+ title: i18n.t('This month'),
62
+ swaps,
63
+ },
64
+ ];
65
+ return (
66
+ <>
67
+ {loadingGroups.map((group) => (
68
+ <Group key={group.title}>
69
+ <Time>
70
+ <Typography
71
+ variant="label"
72
+ size="medium"
73
+ className={groupStyles()}>
74
+ {group.title}
75
+ </Typography>
76
+ </Time>
77
+ <Divider size={4} />
78
+ <SwapList>
79
+ {group.swaps.map((_, index) => {
80
+ const key = index + group.title;
81
+ return <SwapListItem isLoading={true} key={key} />;
82
+ })}
83
+ </SwapList>
84
+ </Group>
85
+ ))}
86
+ </>
87
+ );
88
+ }
89
+
90
+ return (
91
+ <GroupedVirtualizedList
92
+ endReached={() => {
93
+ if (loadedItems.current < list.length) {
94
+ loadMore();
95
+ }
96
+ }}
97
+ groupCounts={currentGroupCounts}
98
+ groupContent={(index) => {
99
+ return (
100
+ <Group>
101
+ <Time>
102
+ <Typography
103
+ variant="label"
104
+ size="medium"
105
+ className={groupStyles()}>
106
+ {groups[index]}
107
+ </Typography>
108
+ </Time>
109
+ </Group>
110
+ );
111
+ }}
112
+ itemContent={(index, groupIndex) => {
113
+ const swap = swaps[index];
114
+ const firstStep = swap.steps[0];
115
+ const lastStep = swap.steps[swap.steps.length - 1];
116
+ return (
117
+ <SwapItemContainer key={swap.requestId}>
118
+ <SwapListItem
119
+ requestId={swap.requestId}
120
+ creationTime={swap.creationTime}
121
+ status={swap.status}
122
+ onClick={onSwapClick}
123
+ tooltipContainer={getContainer()}
124
+ onlyShowTime={groups[groupIndex] === i18n.t('Today')}
125
+ swapTokenData={{
126
+ from: {
127
+ token: {
128
+ image: firstStep.fromLogo,
129
+ displayName: firstStep.fromSymbol,
130
+ },
131
+ blockchain: {
132
+ image: firstStep.fromBlockchainLogo || '',
133
+ },
134
+ amount: numberToString(
135
+ swap.inputAmount,
136
+ TOKEN_AMOUNT_MIN_DECIMALS,
137
+ TOKEN_AMOUNT_MAX_DECIMALS
138
+ ),
139
+ realAmount: formatTooltipNumbers(swap.inputAmount),
140
+ },
141
+ to: {
142
+ token: {
143
+ image: lastStep.toLogo,
144
+ displayName: lastStep.toSymbol,
145
+ },
146
+ blockchain: {
147
+ image: lastStep.toBlockchainLogo || '',
148
+ },
149
+ amount: numberToString(
150
+ lastStep.outputAmount ||
151
+ lastStep.expectedOutputAmountHumanReadable ||
152
+ '',
153
+ TOKEN_AMOUNT_MIN_DECIMALS,
154
+ TOKEN_AMOUNT_MAX_DECIMALS
155
+ ),
156
+ realAmount: formatTooltipNumbers(
157
+ lastStep.outputAmount ||
158
+ lastStep.expectedOutputAmountHumanReadable
159
+ ),
160
+ },
161
+ }}
162
+ />
163
+ </SwapItemContainer>
164
+ );
165
+ }}
166
+ />
167
+ );
168
+ }
@@ -1,13 +1,14 @@
1
1
  import type { PendingSwap } from 'rango-types';
2
2
 
3
3
  export type GroupBy = (list: PendingSwap[]) => {
4
- title: string;
5
4
  swaps: PendingSwap[];
6
- }[];
5
+ groups: string[];
6
+ groupCounts: number[];
7
+ };
7
8
 
8
9
  export interface PropTypes {
9
10
  list: PendingSwap[];
10
11
  onSwapClick: (requestId: string) => void;
11
- groupBy?: GroupBy;
12
+ groupBy: GroupBy;
12
13
  isLoading: boolean;
13
14
  }
@@ -0,0 +1 @@
1
+ export { HistoryGroupedList } from './HistoryGroupedList';
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
2
  import type { PropTypes, RenderDescProps } from './TokenList.types';
3
3
  import type { Token } from 'rango-sdk';
4
- import type { CommonProps } from 'react-window';
5
4
 
6
5
  import { i18n } from '@lingui/core';
7
6
  import {
@@ -16,7 +15,7 @@ import {
16
15
  Typography,
17
16
  VirtualizedList,
18
17
  } from '@rango-dev/ui';
19
- import React, { forwardRef, useEffect, useState } from 'react';
18
+ import React, { useEffect, useState } from 'react';
20
19
 
21
20
  import { useAppStore } from '../../store/AppStore';
22
21
  import { useWalletsStore } from '../../store/wallets';
@@ -100,20 +99,6 @@ export function TokenList(props: PropTypes) {
100
99
  const { getBalanceFor, loading: loadingWallet } = useWalletsStore();
101
100
  const { isTokenPinned } = useAppStore();
102
101
 
103
- // eslint-disable-next-line react/display-name
104
- const innerElementType: React.FC<CommonProps> = forwardRef((render, ref) => {
105
- return (
106
- <div
107
- {...render}
108
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
- ref={ref as any}
110
- style={{
111
- ...render.style,
112
- height: `${parseFloat(render.style?.height as string) + 8 * 2}px`,
113
- }}
114
- />
115
- );
116
- });
117
102
  const loadNextPage = () => {
118
103
  setTokens(list.slice(0, tokens.length + PAGE_SIZE));
119
104
  };
@@ -140,7 +125,8 @@ export function TokenList(props: PropTypes) {
140
125
  }
141
126
  return (
142
127
  <VirtualizedList
143
- Item={({ index, style }) => {
128
+ endReached={hasNextPage ? loadNextPage : undefined}
129
+ itemContent={(index) => {
144
130
  const token = tokens[index];
145
131
  const tokenBalance = formatBalance(getBalanceFor(token));
146
132
  const address = token.address || '';
@@ -171,12 +157,10 @@ export function TokenList(props: PropTypes) {
171
157
  return (
172
158
  <div
173
159
  style={{
174
- ...style,
175
160
  paddingRight: 5,
176
161
  }}>
177
162
  <ListItemButton
178
163
  style={{
179
- height: style?.height,
180
164
  width: '100%',
181
165
  overflow: 'hidden',
182
166
  }}
@@ -261,11 +245,7 @@ export function TokenList(props: PropTypes) {
261
245
  </div>
262
246
  );
263
247
  }}
264
- hasNextPage={hasNextPage}
265
- itemCount={tokens.length}
266
- loadNextPage={loadNextPage}
267
- innerElementType={innerElementType}
268
- size={60}
248
+ totalCount={tokens.length}
269
249
  key={`${selectedBlockchain}-${searchedFor}`}
270
250
  />
271
251
  );
@@ -6,15 +6,15 @@ import { Divider, NotFound, styled } from '@rango-dev/ui';
6
6
  import React, { useState } from 'react';
7
7
  import { useNavigate } from 'react-router-dom';
8
8
 
9
+ import { HistoryGroupedList } from '../components/HistoryGroupedList';
10
+ import { NotFoundContainer } from '../components/HistoryGroupedList/HistoryGroupedList.styles';
9
11
  import { Layout, PageContainer } from '../components/Layout';
10
12
  import { SearchInput } from '../components/SearchInput';
11
- import { SwapsGroup } from '../components/SwapsGroup';
12
- import { NotFoundContainer } from '../components/SwapsGroup/SwapsGroup.styles';
13
13
  import { groupSwapsByDate } from '../utils/date';
14
14
  import { containsText } from '../utils/numbers';
15
15
  import { getPendingSwaps } from '../utils/queue';
16
16
 
17
- const SwapsGroupContainer = styled('div', {
17
+ const HistoryGroupedListContainer = styled('div', {
18
18
  overflowY: 'visible',
19
19
  width: '100%',
20
20
  display: 'flex',
@@ -77,7 +77,7 @@ export function HistoryPage() {
77
77
  value={searchedFor}
78
78
  />
79
79
  <Divider size="16" />
80
- <SwapsGroupContainer>
80
+ <HistoryGroupedListContainer>
81
81
  {isEmpty && (
82
82
  <NotFoundContainer>
83
83
  <Divider size={32} />
@@ -90,14 +90,14 @@ export function HistoryPage() {
90
90
  </NotFoundContainer>
91
91
  )}
92
92
  {!isEmpty && (
93
- <SwapsGroup
93
+ <HistoryGroupedList
94
94
  list={filteredList}
95
95
  onSwapClick={navigate}
96
96
  groupBy={groupSwapsByDate}
97
97
  isLoading={loading}
98
98
  />
99
99
  )}
100
- </SwapsGroupContainer>
100
+ </HistoryGroupedListContainer>
101
101
  </PageContainer>
102
102
  </Layout>
103
103
  );
package/src/utils/date.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { GroupBy } from '../components/SwapsGroup/SwapsGroup.types';
1
+ import type { GroupBy } from '../components/HistoryGroupedList/HistoryGroupedList.types';
2
2
  import type { PendingSwap } from 'rango-types';
3
3
 
4
4
  import { i18n } from '@lingui/core';
@@ -70,5 +70,12 @@ export const groupSwapsByDate: GroupBy = (swaps) => {
70
70
  }
71
71
  });
72
72
 
73
- return Array.from(output.values());
73
+ const groupedSwaps = Array.from(output.values()).filter(
74
+ (item) => item.swaps.length > 0
75
+ );
76
+ const items = groupedSwaps.flatMap((group) => group.swaps);
77
+ const groupCounts = groupedSwaps.map((group) => group.swaps.length);
78
+ const groups = groupedSwaps.map((group) => group.title);
79
+
80
+ return { swaps: items, groupCounts, groups };
74
81
  };
@@ -1,4 +0,0 @@
1
- import type { PropTypes } from './SwapsGroup.types';
2
- import React from 'react';
3
- export declare function SwapsGroup(props: PropTypes): React.JSX.Element;
4
- //# sourceMappingURL=SwapsGroup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SwapsGroup.d.ts","sourceRoot":"","sources":["../../../src/components/SwapsGroup/SwapsGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,qBA6H1C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SwapsGroup.styles.d.ts","sourceRoot":"","sources":["../../../src/components/SwapsGroup/SwapsGroup.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAAQ,CAAC;AAEjC,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAWhB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAIf,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAInB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAK5B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SwapsGroup.types.d.ts","sourceRoot":"","sources":["../../../src/components/SwapsGroup/SwapsGroup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB,EAAE,CAAC;AAEJ,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB"}
@@ -1,2 +0,0 @@
1
- export { SwapsGroup } from './SwapsGroup';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SwapsGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -1,141 +0,0 @@
1
- import type { PropTypes } from './SwapsGroup.types';
2
-
3
- import { i18n } from '@lingui/core';
4
- import { Divider, SwapListItem, Typography } from '@rango-dev/ui';
5
- import React from 'react';
6
-
7
- import {
8
- TOKEN_AMOUNT_MAX_DECIMALS,
9
- TOKEN_AMOUNT_MIN_DECIMALS,
10
- } from '../../constants/routing';
11
- import { getContainer } from '../../utils/common';
12
- import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
13
-
14
- import { Group, groupStyles, SwapList, Time } from './SwapsGroup.styles';
15
-
16
- export function SwapsGroup(props: PropTypes) {
17
- const { list, onSwapClick, groupBy, isLoading } = props;
18
- const groups = groupBy ? groupBy(list) : [{ title: 'History', swaps: list }];
19
-
20
- if (isLoading) {
21
- const swaps = [{}, {}];
22
-
23
- const loadingGroups = [
24
- {
25
- title: i18n.t('Today'),
26
- swaps,
27
- },
28
- {
29
- title: i18n.t('This month'),
30
- swaps,
31
- },
32
- ];
33
- return (
34
- <>
35
- {loadingGroups.map((group) => (
36
- <React.Fragment key={group.title}>
37
- <Group>
38
- <Time>
39
- <Typography
40
- variant="label"
41
- size="medium"
42
- className={groupStyles()}>
43
- {group.title}
44
- </Typography>
45
- </Time>
46
- <Divider size={4} />
47
- <SwapList>
48
- {group.swaps.map((_, index) => {
49
- const key = index + group.title;
50
- return (
51
- <React.Fragment key={key}>
52
- <SwapListItem isLoading={true} />
53
- </React.Fragment>
54
- );
55
- })}
56
- </SwapList>
57
- </Group>
58
- </React.Fragment>
59
- ))}
60
- </>
61
- );
62
- }
63
-
64
- return (
65
- <>
66
- {groups
67
- .filter((group) => group.swaps.length > 0)
68
- .map((group) => (
69
- <React.Fragment key={group.title}>
70
- <Group>
71
- <Time>
72
- <Typography
73
- variant="label"
74
- size="medium"
75
- className={groupStyles()}>
76
- {group.title}
77
- </Typography>
78
- </Time>
79
- <Divider size={4} />
80
- <SwapList>
81
- {group.swaps.map((swap) => {
82
- const firstStep = swap.steps[0];
83
-
84
- const lastStep = swap.steps[swap.steps.length - 1];
85
- return (
86
- <React.Fragment key={swap.requestId}>
87
- <SwapListItem
88
- requestId={swap.requestId}
89
- creationTime={swap.creationTime}
90
- status={swap.status}
91
- onClick={onSwapClick}
92
- tooltipContainer={getContainer()}
93
- onlyShowTime={group.title === i18n.t('Today')}
94
- swapTokenData={{
95
- from: {
96
- token: {
97
- image: firstStep.fromLogo,
98
- displayName: firstStep.fromSymbol,
99
- },
100
- blockchain: {
101
- image: firstStep.fromBlockchainLogo || '',
102
- },
103
- amount: numberToString(
104
- swap.inputAmount,
105
- TOKEN_AMOUNT_MIN_DECIMALS,
106
- TOKEN_AMOUNT_MAX_DECIMALS
107
- ),
108
- realAmount: formatTooltipNumbers(swap.inputAmount),
109
- },
110
- to: {
111
- token: {
112
- image: lastStep.toLogo,
113
- displayName: lastStep.toSymbol,
114
- },
115
- blockchain: {
116
- image: lastStep.toBlockchainLogo || '',
117
- },
118
- amount: numberToString(
119
- lastStep.outputAmount ||
120
- lastStep.expectedOutputAmountHumanReadable ||
121
- '',
122
- TOKEN_AMOUNT_MIN_DECIMALS,
123
- TOKEN_AMOUNT_MAX_DECIMALS
124
- ),
125
- realAmount: formatTooltipNumbers(
126
- lastStep.outputAmount ||
127
- lastStep.expectedOutputAmountHumanReadable
128
- ),
129
- },
130
- }}
131
- />
132
- </React.Fragment>
133
- );
134
- })}
135
- </SwapList>
136
- </Group>
137
- </React.Fragment>
138
- ))}
139
- </>
140
- );
141
- }
@@ -1 +0,0 @@
1
- export { SwapsGroup } from './SwapsGroup';