-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted connect bank account into seperate component, and added off…
…line message
- Loading branch information
1 parent
5723571
commit 763371a
Showing
6 changed files
with
73 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {View} from 'react-native'; | ||
import * as ReimbursementAccount from '../libs/actions/ReimbursementAccount'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import styles from '../styles/styles'; | ||
import Button from './Button'; | ||
import {withNetwork} from './OnyxProvider'; | ||
import compose from '../libs/compose'; | ||
import withLocalize, {withLocalizePropTypes} from './withLocalize'; | ||
import networkPropTypes from './networkPropTypes'; | ||
import Text from './Text'; | ||
|
||
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) { | ||
if (props.network.isOffline) { | ||
return ( | ||
<View style={props.style}> | ||
<Text>{`${props.translate('common.youAppearToBeOffline')} ${props.translate('common.thisFeatureRequiresInternet')}`}</Text> | ||
</View> | ||
); | ||
} | ||
|
||
return ( | ||
<Button | ||
text={props.translate('workspace.common.connectBankAccount')} | ||
onPress={() => ReimbursementAccount.navigateToBankAccountRoute(props.policyID)} | ||
icon={Expensicons.Bank} | ||
style={props.style} | ||
iconStyles={[styles.buttonCTAIcon]} | ||
shouldShowRightIcon | ||
large | ||
success | ||
/> | ||
); | ||
} | ||
|
||
ConnectBankAccountButton.propTypes = propTypes; | ||
ConnectBankAccountButton.defaultProps = defaultProps; | ||
ConnectBankAccountButton.displayName = 'ConfirmPopover'; | ||
|
||
export default compose(withNetwork(), withLocalize)(ConnectBankAccountButton); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters