diff --git a/src/components/FormAlertWithSubmitButton.js b/src/components/FormAlertWithSubmitButton.js index 82cff4bf3838..1e158d63635c 100644 --- a/src/components/FormAlertWithSubmitButton.js +++ b/src/components/FormAlertWithSubmitButton.js @@ -1,53 +1,36 @@ -import _ from 'underscore'; import React from 'react'; -import {View} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../styles/styles'; -import Icon from './Icon'; -import * as Expensicons from './Icon/Expensicons'; -import colors from '../styles/colors'; -import compose from '../libs/compose'; import Button from './Button'; -import withLocalize, {withLocalizePropTypes} from './withLocalize'; -import TextLink from './TextLink'; -import Text from './Text'; -import RenderHTML from './RenderHTML'; -import OfflineIndicator from './OfflineIndicator'; -import networkPropTypes from './networkPropTypes'; -import {withNetwork} from './OnyxProvider'; +import FormAlertWrapper from './FormAlertWrapper'; const propTypes = { + /** Text for the button */ + buttonText: PropTypes.string.isRequired, + + /** Styles for container element */ + containerStyles: PropTypes.arrayOf(PropTypes.object), + /** Whether to show the alert text */ isAlertVisible: PropTypes.bool.isRequired, /** Whether the button is disabled */ isDisabled: PropTypes.bool, - /** Submit function */ - onSubmit: PropTypes.func.isRequired, - - /** Text for the button */ - buttonText: PropTypes.string.isRequired, - - /** Callback fired when the "fix the errors" link is pressed */ - onFixTheErrorsLinkPressed: PropTypes.func, - - /** Error message to display above button */ - message: PropTypes.string, + /** Is the button in a loading state */ + isLoading: PropTypes.bool, /** Whether message is in html format */ isMessageHtml: PropTypes.bool, - /** Styles for container element */ - containerStyles: PropTypes.arrayOf(PropTypes.object), - - /** Is the button in a loading state */ - isLoading: PropTypes.bool, + /** Error message to display above button */ + message: PropTypes.string, - ...withLocalizePropTypes, + /** Callback fired when the "fix the errors" link is pressed */ + onFixTheErrorsPressed: PropTypes.func, - /** Props to detect online status */ - network: networkPropTypes.isRequired, + /** Submit function */ + onSubmit: PropTypes.func.isRequired, }; const defaultProps = { @@ -56,74 +39,25 @@ const defaultProps = { isMessageHtml: false, containerStyles: [], isLoading: false, - onFixTheErrorsLinkPressed: () => {}, + onFixTheErrorsPressed: () => {}, }; -const FormAlertWithSubmitButton = (props) => { - /** - * @returns {React.Component} - */ - function getAlertPrompt() { - let error = ''; - - if (!_.isEmpty(props.message)) { - if (props.isMessageHtml) { - error = ( - ${props.message}`} /> - ); - } else { - error = ( - {props.message} - ); - } - } else { - error = ( - <> - - {`${props.translate('common.please')} `} - - - {props.translate('common.fixTheErrors')} - - - {` ${props.translate('common.inTheFormBeforeContinuing')}.`} - - - ); - } - - return ( - - {error} - - ); - } - - if (props.network.isOffline) { - return ( - -