From 9279e3f9fa2a31352d8b8dc4e1c330a45b0c8ee3 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Thu, 11 Jan 2024 11:45:28 +0100 Subject: [PATCH 1/5] Add disable fix alert prop --- src/components/Form/FormProvider.js | 3 +++ src/components/Form/FormWrapper.js | 7 ++++++- src/pages/EnablePayments/IdologyQuestions.js | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Form/FormProvider.js b/src/components/Form/FormProvider.js index 50b24e368fc6..dececd7b7fba 100644 --- a/src/components/Form/FormProvider.js +++ b/src/components/Form/FormProvider.js @@ -73,6 +73,8 @@ const propTypes = { /** Should validate function be called when the value of the input is changed */ shouldValidateOnChange: PropTypes.bool, + + shouldHideFixErrorsAlert: PropTypes.bool, }; // In order to prevent Checkbox focus loss when the user are focusing a TextInput and proceeds to toggle a CheckBox in web and mobile web. @@ -94,6 +96,7 @@ const defaultProps = { validate: () => {}, shouldValidateOnBlur: true, shouldValidateOnChange: true, + shouldHideFixErrorsAlert: false, }; function getInitialValueByType(valueType) { diff --git a/src/components/Form/FormWrapper.js b/src/components/Form/FormWrapper.js index da34262a8af8..7dd8ca9dd3d0 100644 --- a/src/components/Form/FormWrapper.js +++ b/src/components/Form/FormWrapper.js @@ -66,6 +66,8 @@ const propTypes = { errors: errorsPropType.isRequired, inputRefs: PropTypes.objectOf(refPropTypes).isRequired, + + shouldHideFixErrorsAlert: PropTypes.bool, }; const defaultProps = { @@ -79,6 +81,7 @@ const defaultProps = { footerContent: null, style: [], submitButtonStyles: [], + shouldHideFixErrorsAlert: false, }; function FormWrapper(props) { @@ -97,6 +100,7 @@ function FormWrapper(props) { enabledWhenOffline, isSubmitActionDangerous, formID, + shouldHideFixErrorsAlert, } = props; const formRef = useRef(null); const formContentRef = useRef(null); @@ -117,7 +121,7 @@ function FormWrapper(props) { {isSubmitButtonVisible && ( 0 || Boolean(errorMessage) || !_.isEmpty(formState.errorFields)} + isAlertVisible={(_.size(errors) > 0 || Boolean(errorMessage) || !_.isEmpty(formState.errorFields)) && !shouldHideFixErrorsAlert} isLoading={formState.isLoading} message={_.isEmpty(formState.errorFields) ? errorMessage : null} onSubmit={onSubmit} @@ -153,6 +157,7 @@ function FormWrapper(props) { enabledWhenOffline={enabledWhenOffline} isSubmitActionDangerous={isSubmitActionDangerous} disablePressOnEnter + shouldHideFixErrorsAlert={shouldHideFixErrorsAlert} /> )} diff --git a/src/pages/EnablePayments/IdologyQuestions.js b/src/pages/EnablePayments/IdologyQuestions.js index 8f21d68abe4f..a0c202b0bbbc 100644 --- a/src/pages/EnablePayments/IdologyQuestions.js +++ b/src/pages/EnablePayments/IdologyQuestions.js @@ -139,6 +139,7 @@ function IdologyQuestions({questions, idNumber}) { scrollContextEnabled style={[styles.flexGrow1, styles.ph5]} submitButtonText={translate('common.saveAndContinue')} + shouldHideFixErrorsAlert > Date: Thu, 11 Jan 2024 13:17:24 +0100 Subject: [PATCH 2/5] Lint fix --- src/components/Form/FormWrapper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Form/FormWrapper.js b/src/components/Form/FormWrapper.js index 7dd8ca9dd3d0..6c6212097eb0 100644 --- a/src/components/Form/FormWrapper.js +++ b/src/components/Form/FormWrapper.js @@ -181,6 +181,7 @@ function FormWrapper(props) { styles.mt5, submitButtonStyles, submitButtonText, + shouldHideFixErrorsAlert, ], ); From 4e3c05017c94bdf6e4821f8a3db087e010cc299b Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Fri, 12 Jan 2024 12:34:15 +0100 Subject: [PATCH 3/5] Fix isAlertVisible calculation --- src/components/Form/FormWrapper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Form/FormWrapper.js b/src/components/Form/FormWrapper.js index 6c6212097eb0..f1c5d6de9071 100644 --- a/src/components/Form/FormWrapper.js +++ b/src/components/Form/FormWrapper.js @@ -121,7 +121,7 @@ function FormWrapper(props) { {isSubmitButtonVisible && ( 0 || Boolean(errorMessage) || !_.isEmpty(formState.errorFields)) && !shouldHideFixErrorsAlert} + isAlertVisible={((_.size(errors) > 0 || !_.isEmpty(formState.errorFields)) && !shouldHideFixErrorsAlert) || Boolean(errorMessage)} isLoading={formState.isLoading} message={_.isEmpty(formState.errorFields) ? errorMessage : null} onSubmit={onSubmit} From 389e04a9fe428e28fe3ecb5ed43a0b42d3c053c1 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Fri, 12 Jan 2024 15:21:44 +0100 Subject: [PATCH 4/5] Add comment --- src/components/Form/FormProvider.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Form/FormProvider.js b/src/components/Form/FormProvider.js index dececd7b7fba..4d1630dbbe06 100644 --- a/src/components/Form/FormProvider.js +++ b/src/components/Form/FormProvider.js @@ -74,6 +74,7 @@ const propTypes = { /** Should validate function be called when the value of the input is changed */ shouldValidateOnChange: PropTypes.bool, + /** Should fix the errors alert be displayed when there is an error in the form */ shouldHideFixErrorsAlert: PropTypes.bool, }; From e99fbed92223a8277fa6e9dc763aa961d832baf0 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Mon, 15 Jan 2024 11:45:43 +0100 Subject: [PATCH 5/5] Add padding to error in radio buttons --- src/components/RadioButtons.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/RadioButtons.tsx b/src/components/RadioButtons.tsx index 8aa3ef7e8ffe..cb6843af65c0 100644 --- a/src/components/RadioButtons.tsx +++ b/src/components/RadioButtons.tsx @@ -1,4 +1,5 @@ import React, {useState} from 'react'; +import {View} from 'react-native'; import useThemeStyles from '@hooks/useThemeStyles'; import RadioButtonWithLabel from './RadioButtonWithLabel'; @@ -20,7 +21,7 @@ function RadioButtons({items, onPress}: RadioButtonsProps) { const [checkedValue, setCheckedValue] = useState(''); return ( - <> + {items.map((item) => ( ))} - + ); }