From 763371a48a009ced29af1934b8e0d18603b368ca Mon Sep 17 00:00:00 2001 From: Ali Toshmatov Date: Fri, 7 Jul 2023 14:48:03 +0500 Subject: [PATCH 1/2] Extracted connect bank account into seperate component, and added offline message --- src/components/ConnectBankAccountButton.js | 58 +++++++++++++++++++ .../bills/WorkspaceBillsNoVBAView.js | 14 +---- .../workspace/card/WorkspaceCardNoVBAView.js | 14 +---- .../invoices/WorkspaceInvoicesNoVBAView.js | 14 +---- .../reimburse/WorkspaceReimburseSection.js | 13 +---- .../travel/WorkspaceTravelNoVBAView.js | 14 +---- 6 files changed, 73 insertions(+), 54 deletions(-) create mode 100644 src/components/ConnectBankAccountButton.js diff --git a/src/components/ConnectBankAccountButton.js b/src/components/ConnectBankAccountButton.js new file mode 100644 index 000000000000..d41fdf0b69d3 --- /dev/null +++ b/src/components/ConnectBankAccountButton.js @@ -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 ( + + {`${props.translate('common.youAppearToBeOffline')} ${props.translate('common.thisFeatureRequiresInternet')}`} + + ); + } + + return ( +