-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathBalanceEmptyState.tsx
More file actions
122 lines (116 loc) · 3.72 KB
/
Copy pathBalanceEmptyState.tsx
File metadata and controls
122 lines (116 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React from 'react';
import { Image } from 'react-native';
import { useSelector } from 'react-redux';
import {
Box,
Button,
ButtonSize,
Text,
TextVariant,
TextColor,
BoxBackgroundColor,
BoxFlexDirection,
BoxAlignItems,
BoxJustifyContent,
FontWeight,
} from '@metamask/design-system-react-native';
import { useTailwind } from '@metamask/design-system-twrnc-preset';
import { strings } from '../../../../locales/i18n';
import { MetaMetricsEvents } from '../../../core/Analytics';
import { useAnalytics } from '../../hooks/useAnalytics/useAnalytics';
import { getDecimalChainId } from '../../../util/networks';
import { selectChainId } from '../../../selectors/networkController';
import { trace, TraceName } from '../../../util/trace';
import { useRampNavigation } from '../Ramp/hooks/useRampNavigation';
import { BalanceEmptyStateProps } from './BalanceEmptyState.types';
import bankTransferImage from '../../../images/bank-transfer.png';
import { getDetectedGeolocation } from '../../../reducers/fiatOrders';
import { useRampsButtonClickData } from '../Ramp/hooks/useRampsButtonClickData';
/**
* BalanceEmptyState smart component displays an empty state for wallet balance
* with an illustration, title, subtitle, and action button that navigates to deposit flow.
*/
const BalanceEmptyState: React.FC<BalanceEmptyStateProps> = ({
testID = 'balance-empty-state',
...props
}) => {
const tw = useTailwind();
const chainId = useSelector(selectChainId);
const { trackEvent, createEventBuilder } = useAnalytics();
const rampGeodetectedRegion = useSelector(getDetectedGeolocation);
const { goToBuy } = useRampNavigation();
const buttonClickData = useRampsButtonClickData();
const handleAction = () => {
goToBuy();
trackEvent(
createEventBuilder(MetaMetricsEvents.RAMPS_BUTTON_CLICKED)
.addProperties({
button_text: 'Add funds',
location: 'BalanceEmptyState',
chain_id_destination: getDecimalChainId(chainId),
ramp_type: 'UNIFIED_BUY_2',
region: rampGeodetectedRegion,
is_authenticated: buttonClickData.is_authenticated,
preferred_provider: buttonClickData.preferred_provider,
order_count: buttonClickData.order_count,
})
.build(),
);
trace({
name: TraceName.LoadRampExperience,
});
};
return (
<Box
paddingLeft={4}
paddingRight={4}
paddingTop={3}
paddingBottom={4}
justifyContent={BoxJustifyContent.Center}
backgroundColor={BoxBackgroundColor.BackgroundSection}
gap={5}
testID={testID}
{...props}
twClassName={`rounded-2xl ${props?.twClassName ?? ''}`}
>
<Box
flexDirection={BoxFlexDirection.Column}
gap={1}
alignItems={BoxAlignItems.Center}
>
<Image
source={bankTransferImage}
style={tw.style('w-[100px] h-[100px]')}
resizeMode="cover"
testID={`${testID}-image`}
/>
<Text
variant={TextVariant.HeadingLg}
color={TextColor.TextDefault}
twClassName="text-center"
testID={`${testID}-title`}
>
{strings('wallet.fund_your_wallet')}
</Text>
<Text
variant={TextVariant.BodyMd}
color={TextColor.TextAlternative}
fontWeight={FontWeight.Medium}
twClassName="text-center"
testID={`${testID}-subtitle`}
>
{strings('wallet.get_ready_for_web3')}
</Text>
</Box>
<Button
size={ButtonSize.Lg}
onPress={handleAction}
isFullWidth
testID={`${testID}-action-button`}
>
{strings('wallet.add_funds')}
</Button>
</Box>
);
};
export default BalanceEmptyState;