Skip to content

Commit 5d2232f

Browse files
feat: implement BatchSellEmptyState component and update BatchSellTokenSelect to use it
1 parent 7c54453 commit 5d2232f

5 files changed

Lines changed: 75 additions & 82 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React from 'react';
2+
import { Image } from 'react-native';
3+
import { SafeAreaView } from 'react-native-safe-area-context';
4+
import { useTailwind } from '@metamask/design-system-twrnc-preset';
5+
import {
6+
Box,
7+
BoxAlignItems,
8+
BoxJustifyContent,
9+
Button,
10+
ButtonSize,
11+
ButtonVariant,
12+
Text,
13+
TextColor,
14+
TextVariant,
15+
} from '@metamask/design-system-react-native';
16+
import { strings } from '../../../../../../locales/i18n';
17+
import emptyStateDefiLight from '../../../../../images/empty-state-defi-light.png';
18+
import { BatchSellTokenSelectSelectorsIDs } from './BatchSellTokenSelect.testIds';
19+
20+
interface BatchSellEmptyStateProps {
21+
onExploreTokensPress: () => void;
22+
}
23+
24+
export function BatchSellEmptyState({
25+
onExploreTokensPress,
26+
}: BatchSellEmptyStateProps) {
27+
const tw = useTailwind();
28+
29+
return (
30+
<SafeAreaView style={tw.style('flex-1 bg-default')} edges={['bottom']}>
31+
<Box
32+
testID={BatchSellTokenSelectSelectorsIDs.EMPTY_STATE}
33+
alignItems={BoxAlignItems.Center}
34+
justifyContent={BoxJustifyContent.Center}
35+
gap={3}
36+
twClassName="flex-1 px-4 py-4"
37+
>
38+
<Image
39+
source={emptyStateDefiLight}
40+
resizeMode="contain"
41+
style={tw.style('h-[72px] w-[72px]')}
42+
/>
43+
<Box alignItems={BoxAlignItems.Center} gap={3} twClassName="px-4">
44+
<Text
45+
variant={TextVariant.BodyMd}
46+
color={TextColor.TextAlternative}
47+
twClassName="w-[240px] text-center"
48+
>
49+
{strings('bridge.batch_sell_empty_state_description')}
50+
</Text>
51+
<Button
52+
variant={ButtonVariant.Secondary}
53+
size={ButtonSize.Lg}
54+
onPress={onExploreTokensPress}
55+
twClassName="self-center"
56+
testID={BatchSellTokenSelectSelectorsIDs.EXPLORE_TOKENS_BUTTON}
57+
>
58+
{strings('bridge.explore_tokens')}
59+
</Button>
60+
</Box>
61+
</Box>
62+
</SafeAreaView>
63+
);
64+
}

app/components/UI/Bridge/Views/BatchSellTokenSelect/BatchSellTokenSelect.test.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
sortBatchSellTokens,
1414
} from './BatchSellTokenSelect.utils';
1515
import Routes from '../../../../../constants/navigation/Routes';
16-
import AppConstants from '../../../../../core/AppConstants';
1716
import { BridgeTokenMetadata } from '../../constants/tokens';
1817
import {
1918
TextColor as ComponentLibraryTextColor,
@@ -775,7 +774,9 @@ describe('BatchSellTokenSelect', () => {
775774

776775
const { getByText, queryByTestId } = render(<BatchSellTokenSelect />);
777776

778-
expect(getByText('No tokens. No problem.')).toBeOnTheScreen();
777+
expect(
778+
getByText('No tokens. No problem. Explore and buy tokens to batch sell.'),
779+
).toBeOnTheScreen();
779780
expect(
780781
queryByTestId(BatchSellTokenSelectSelectorsIDs.NEXT_BUTTON),
781782
).not.toBeOnTheScreen();
@@ -790,12 +791,8 @@ describe('BatchSellTokenSelect', () => {
790791
getByTestId(BatchSellTokenSelectSelectorsIDs.EXPLORE_TOKENS_BUTTON),
791792
);
792793

793-
expect(mockNavigate).toHaveBeenCalledWith(Routes.BROWSER.HOME, {
794-
screen: Routes.BROWSER.VIEW,
795-
params: {
796-
newTabUrl: AppConstants.EXPLORE_TOKENS.URL,
797-
timestamp: expect.any(Number),
798-
},
794+
expect(mockNavigate).toHaveBeenCalledWith(Routes.TRENDING_VIEW, {
795+
screen: Routes.TRENDING_FEED,
799796
});
800797
});
801798

app/components/UI/Bridge/Views/BatchSellTokenSelect/BatchSellTokenSelect.testIds.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ export const BatchSellTokenSelectSelectorsIDs = {
55
NEXT_BUTTON: 'batch-sell-token-select-next-button',
66
EMPTY_STATE: 'batch-sell-token-select-empty-state',
77
EXPLORE_TOKENS_BUTTON: 'batch-sell-token-select-explore-tokens-button',
8-
SEARCH_EMPTY_STATE: 'batch-sell-token-select-search-empty-state',
98
BALANCE_SORT_BUTTON: 'batch-sell-token-select-balance-sort-button',
109
};

app/components/UI/Bridge/Views/BatchSellTokenSelect/BatchSellTokenSelect.tsx

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useNavigation } from '@react-navigation/native';
22
import React, { useCallback, useEffect, useMemo, useState } from 'react';
3-
import { Image, ListRenderItemInfo, Pressable } from 'react-native';
3+
import { ListRenderItemInfo, Pressable } from 'react-native';
44
import { FlatList, ScrollView } from 'react-native-gesture-handler';
55
import { SafeAreaView } from 'react-native-safe-area-context';
66
import { useDispatch, useSelector } from 'react-redux';
@@ -12,7 +12,6 @@ import {
1212
Box,
1313
BoxAlignItems,
1414
BoxFlexDirection,
15-
BoxJustifyContent,
1615
Button,
1716
ButtonSize,
1817
ButtonVariant,
@@ -30,7 +29,6 @@ import { CaipChainId } from '@metamask/utils';
3029

3130
import { getHeaderCompactStandardNavbarOptions } from '../../../../../component-library/components-temp/HeaderCompactStandard';
3231
import { strings } from '../../../../../../locales/i18n';
33-
import AppConstants from '../../../../../core/AppConstants';
3432
import Routes from '../../../../../constants/navigation/Routes';
3533
import {
3634
selectBatchSellDestStablecoinsByChain,
@@ -41,7 +39,6 @@ import { useTokensWithBalance } from '../../hooks/useTokensWithBalance';
4139
import ButtonToggle from '../../../../../component-library/components-temp/Buttons/ButtonToggle';
4240
import { ButtonSize as ButtonToggleSize } from '../../../../../component-library/components/Buttons/Button';
4341
import { getNetworkImageSource } from '../../../../../util/networks';
44-
import emptyStateDefiLight from '../../../../../images/empty-state-defi-light.png';
4542
import {
4643
buildBatchSellEligibleChains,
4744
removeStablecoinsFromSourceTokens,
@@ -53,6 +50,7 @@ import {
5350
} from './BatchSellTokenSelect.utils';
5451
import { BatchSellTokenSelectSelectorsIDs } from './BatchSellTokenSelect.testIds';
5552
import { BatchSellTokenRow } from './BatchSellTokenRow';
53+
import { BatchSellEmptyState } from './BatchSellEmptyState';
5654

5755
const getTokenKey = (token: BridgeToken) =>
5856
`${formatChainIdToCaip(token.chainId)}:${token.address}`;
@@ -220,12 +218,8 @@ export function BatchSellTokenSelect() {
220218
}, [dispatch, navigation, selectedTokens, stablecoinsByChain]);
221219

222220
const handleExploreTokensPress = useCallback(() => {
223-
navigation.navigate(Routes.BROWSER.HOME, {
224-
screen: Routes.BROWSER.VIEW,
225-
params: {
226-
newTabUrl: AppConstants.EXPLORE_TOKENS.URL,
227-
timestamp: Date.now(),
228-
},
221+
navigation.navigate(Routes.TRENDING_VIEW, {
222+
screen: Routes.TRENDING_FEED,
229223
});
230224
}, [navigation]);
231225

@@ -308,45 +302,7 @@ export function BatchSellTokenSelect() {
308302

309303
if (eligibleSourceTokens.length === 0) {
310304
return (
311-
<SafeAreaView style={tw.style('flex-1 bg-default')} edges={['bottom']}>
312-
<Box
313-
testID={BatchSellTokenSelectSelectorsIDs.EMPTY_STATE}
314-
alignItems={BoxAlignItems.Center}
315-
justifyContent={BoxJustifyContent.Center}
316-
twClassName="flex-1 px-8"
317-
>
318-
<Image
319-
source={emptyStateDefiLight}
320-
resizeMode="contain"
321-
style={tw.style('h-[96px] w-[96px] mb-6')}
322-
/>
323-
<Text
324-
variant={TextVariant.HeadingMd}
325-
color={TextColor.TextDefault}
326-
twClassName="text-center"
327-
>
328-
{strings('bridge.batch_sell_empty_state_title')}
329-
</Text>
330-
<Text
331-
variant={TextVariant.BodyMd}
332-
color={TextColor.TextAlternative}
333-
twClassName="mt-2 text-center"
334-
>
335-
{strings('bridge.batch_sell_empty_state_description')}
336-
</Text>
337-
<Box twClassName="mt-6 w-full">
338-
<Button
339-
variant={ButtonVariant.Secondary}
340-
size={ButtonSize.Lg}
341-
isFullWidth
342-
onPress={handleExploreTokensPress}
343-
testID={BatchSellTokenSelectSelectorsIDs.EXPLORE_TOKENS_BUTTON}
344-
>
345-
{strings('bridge.explore_tokens')}
346-
</Button>
347-
</Box>
348-
</Box>
349-
</SafeAreaView>
305+
<BatchSellEmptyState onExploreTokensPress={handleExploreTokensPress} />
350306
);
351307
}
352308

@@ -420,28 +376,6 @@ export function BatchSellTokenSelect() {
420376
keyExtractor={getTokenKey}
421377
showsVerticalScrollIndicator={false}
422378
contentContainerStyle={tw.style('pb-4')}
423-
ListEmptyComponent={
424-
<Box
425-
testID={BatchSellTokenSelectSelectorsIDs.SEARCH_EMPTY_STATE}
426-
alignItems={BoxAlignItems.Center}
427-
twClassName="px-8 py-20"
428-
>
429-
<Text
430-
variant={TextVariant.HeadingMd}
431-
color={TextColor.TextDefault}
432-
twClassName="text-center"
433-
>
434-
{strings('bridge.no_tokens_found')}
435-
</Text>
436-
<Text
437-
variant={TextVariant.BodyMd}
438-
color={TextColor.TextAlternative}
439-
twClassName="mt-2 text-center"
440-
>
441-
{strings('bridge.no_tokens_found_description')}
442-
</Text>
443-
</Box>
444-
}
445379
/>
446380
<Box twClassName="border-t border-muted px-4 pb-4 pt-3">
447381
<Button

locales/languages/en.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7161,7 +7161,7 @@
71617161
"batch_sell_select_title": "Select up to 5 tokens",
71627162
"batch_sell_select_subtitle": "All tokens need to be on the same network.",
71637163
"batch_sell_empty_state_title": "No tokens. No problem.",
7164-
"batch_sell_empty_state_description": "Explore and buy tokens to batch sell.",
7164+
"batch_sell_empty_state_description": "No tokens. No problem. Explore and buy tokens to batch sell.",
71657165
"batch_sell_continue_with_one_token": "Continue with (1) token",
71667166
"batch_sell_continue_with_tokens": "Continue with ({{tokenCount}}) tokens",
71677167
"batch_sell_max_tokens_allowed": "Max 5 tokens allowed",
@@ -7171,7 +7171,6 @@
71717171
"batch_sell_checkbox_label": "Batch Sell token",
71727172
"sort_balance": "Balance",
71737173
"next": "Next",
7174-
"cancel": "Cancel",
71757174
"explore_tokens": "Explore tokens",
71767175
"no_tokens_found": "No tokens found",
71777176
"no_tokens_found_description": "We couldn't find any tokens with this name. Try a different search.",

0 commit comments

Comments
 (0)