From 76bf1313e6e9083867a800445145f4ec04c1a136 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 14 Nov 2023 13:21:46 +0100 Subject: [PATCH 1/4] ref: started moving FormAlertWithSubmitButton to Typescript --- src/components/FormAlertWithSubmitButton.js | 113 ------------------- src/components/FormAlertWithSubmitButton.tsx | 104 +++++++++++++++++ 2 files changed, 104 insertions(+), 113 deletions(-) delete mode 100644 src/components/FormAlertWithSubmitButton.js create mode 100644 src/components/FormAlertWithSubmitButton.tsx diff --git a/src/components/FormAlertWithSubmitButton.js b/src/components/FormAlertWithSubmitButton.js deleted file mode 100644 index 1ffbf0d667e2..000000000000 --- a/src/components/FormAlertWithSubmitButton.js +++ /dev/null @@ -1,113 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import {View} from 'react-native'; -import _ from 'underscore'; -import styles from '@styles/styles'; -import Button from './Button'; -import FormAlertWrapper from './FormAlertWrapper'; - -const propTypes = { - /** Text for the button */ - buttonText: PropTypes.string.isRequired, - - /** Styles for container element */ - // eslint-disable-next-line react/forbid-prop-types - containerStyles: PropTypes.arrayOf(PropTypes.object), - - /** Whether to show the alert text */ - isAlertVisible: PropTypes.bool.isRequired, - - /** Whether the button is disabled */ - isDisabled: PropTypes.bool, - - /** Is the button in a loading state */ - isLoading: PropTypes.bool, - - /** Whether message is in html format */ - isMessageHtml: PropTypes.bool, - - /** Error message to display above button */ - message: PropTypes.string, - - /** Callback fired when the "fix the errors" link is pressed */ - onFixTheErrorsLinkPressed: PropTypes.func, - - /** Submit function */ - onSubmit: PropTypes.func.isRequired, - - /** Should the button be enabled when offline */ - enabledWhenOffline: PropTypes.bool, - - /** Disable press on enter for submit button */ - disablePressOnEnter: PropTypes.bool, - - /** Whether the form submit action is dangerous */ - isSubmitActionDangerous: PropTypes.bool, - - /** Custom content to display in the footer after submit button */ - footerContent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]), - - /** Styles for the button */ - // eslint-disable-next-line react/forbid-prop-types - buttonStyles: PropTypes.arrayOf(PropTypes.object), -}; - -const defaultProps = { - message: '', - isDisabled: false, - isMessageHtml: false, - containerStyles: [], - isLoading: false, - onFixTheErrorsLinkPressed: () => {}, - enabledWhenOffline: false, - disablePressOnEnter: false, - isSubmitActionDangerous: false, - footerContent: null, - buttonStyles: [], -}; - -function FormAlertWithSubmitButton(props) { - const buttonStyles = [_.isEmpty(props.footerContent) ? {} : styles.mb3, ...props.buttonStyles]; - - return ( - - {(isOffline) => ( - - {isOffline && !props.enabledWhenOffline ? ( -