diff --git a/src/CONST.js b/src/CONST.js
index 59403775effa..47effb8a5b2c 100755
--- a/src/CONST.js
+++ b/src/CONST.js
@@ -418,6 +418,7 @@ const CONST = {
},
DEFAULT_TIME_ZONE: {automatic: true, selected: 'America/Los_Angeles'},
DEFAULT_ACCOUNT_DATA: {errors: null, success: '', isLoading: false},
+ DEFAULT_CLOSE_ACCOUNT_DATA: {error: '', success: '', isLoading: false},
APP_STATE: {
ACTIVE: 'active',
BACKGROUND: 'background',
diff --git a/src/libs/actions/CloseAccount.js b/src/libs/actions/CloseAccount.js
index a42db97529ef..d8091f25bdb2 100644
--- a/src/libs/actions/CloseAccount.js
+++ b/src/libs/actions/CloseAccount.js
@@ -1,5 +1,6 @@
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../../ONYXKEYS';
+import CONST from '../../CONST';
/**
* Clear CloseAccount error message to hide modal
@@ -8,7 +9,15 @@ function clearError() {
Onyx.merge(ONYXKEYS.CLOSE_ACCOUNT, {error: ''});
}
+/**
+ * Set default Onyx data
+ */
+function setDefaultData() {
+ Onyx.merge(ONYXKEYS.CLOSE_ACCOUNT, {...CONST.DEFAULT_CLOSE_ACCOUNT_DATA});
+}
+
export {
// eslint-disable-next-line import/prefer-default-export
clearError,
+ setDefaultData,
};
diff --git a/src/pages/settings/Security/CloseAccountPage.js b/src/pages/settings/Security/CloseAccountPage.js
index 22baa8d66a36..f190cb67ece9 100644
--- a/src/pages/settings/Security/CloseAccountPage.js
+++ b/src/pages/settings/Security/CloseAccountPage.js
@@ -18,6 +18,9 @@ import withLocalize, {withLocalizePropTypes} from '../../../components/withLocal
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import * as CloseAccount from '../../../libs/actions/CloseAccount';
import ONYXKEYS from '../../../ONYXKEYS';
+import OfflineIndicator from '../../../components/OfflineIndicator';
+import {withNetwork} from '../../../components/OnyxProvider';
+import networkPropTypes from '../../../components/networkPropTypes';
const propTypes = {
/** Onyx Props */
@@ -37,6 +40,9 @@ const propTypes = {
email: PropTypes.string.isRequired,
}).isRequired,
+ /** Information about the network */
+ network: networkPropTypes.isRequired,
+
...windowDimensionsPropTypes,
...withLocalizePropTypes,
};
@@ -110,9 +116,11 @@ class CloseAccountPage extends Component {
text={this.props.translate('closeAccountPage.closeAccount')}
isLoading={this.props.closeAccount.isLoading}
onPress={() => User.closeAccount(this.state.reasonForLeaving)}
- isDisabled={Str.removeSMSDomain(userEmailOrPhone).toLowerCase() !== this.state.phoneOrEmail.toLowerCase()}
+ isDisabled={Str.removeSMSDomain(userEmailOrPhone).toLowerCase() !== this.state.phoneOrEmail.toLowerCase() || this.props.network.isOffline}
style={[styles.mt5]}
/>
+ {!this.props.isSmallScreenWidth
+ && }
)}
+ {!_.isEmpty(this.props.closeAccount.success) && (
+
+ // DotIndicatorMessage mostly expects onyxData errors, so we need to mock an object so that the messages looks similar to prop.account.errors
+
+ )}
{ // We need to unmount the submit button when the component is not visible so that the Enter button
// key handler gets unsubscribed and does not conflict with the Password Form
this.props.isVisible && (
@@ -203,6 +221,7 @@ LoginForm.defaultProps = defaultProps;
export default compose(
withOnyx({
account: {key: ONYXKEYS.ACCOUNT},
+ closeAccount: {key: ONYXKEYS.CLOSE_ACCOUNT},
}),
withWindowDimensions,
withLocalize,