-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathConnectBankAccountButton.js
57 lines (49 loc) · 2.03 KB
/
ConnectBankAccountButton.js
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
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import useThemeStyles from '@hooks/useThemeStyles';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as ReimbursementAccount from '@userActions/ReimbursementAccount';
import Button from './Button';
import * as Expensicons from './Icon/Expensicons';
import networkPropTypes from './networkPropTypes';
import {withNetwork} from './OnyxProvider';
import Text from './Text';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
const propTypes = {
...withLocalizePropTypes,
/** Information about the network */
network: networkPropTypes.isRequired,
/** PolicyID for navigating to bank account route of that policy */
policyID: PropTypes.string.isRequired,
/** Button styles, also applied for offline message wrapper */
style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]),
};
const defaultProps = {
style: [],
};
function ConnectBankAccountButton(props) {
const styles = useThemeStyles();
const activeRoute = Navigation.getActiveRouteWithoutParams();
return props.network.isOffline ? (
<View style={props.style}>
<Text>{`${props.translate('common.youAppearToBeOffline')} ${props.translate('common.thisFeatureRequiresInternet')}`}</Text>
</View>
) : (
<Button
text={props.translate('workspace.common.connectBankAccount')}
onPress={() => ReimbursementAccount.navigateToBankAccountRoute(props.policyID, activeRoute)}
icon={Expensicons.Bank}
style={props.style}
iconStyles={[styles.buttonCTAIcon]}
shouldShowRightIcon
large
success
/>
);
}
ConnectBankAccountButton.propTypes = propTypes;
ConnectBankAccountButton.defaultProps = defaultProps;
ConnectBankAccountButton.displayName = 'ConnectBankAccountButton';
export default compose(withNetwork(), withLocalize)(ConnectBankAccountButton);