From 4add919636d3e398a22bafa6f55901603183f2f9 Mon Sep 17 00:00:00 2001 From: RohanSasne Date: Wed, 21 Feb 2024 03:21:30 +0530 Subject: [PATCH 01/10] Add whitespace check --- .../substeps/PhoneNumberBusiness.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index e0d369e099d1..3a851b001ff7 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useState} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; @@ -26,10 +26,11 @@ type PhoneNumberBusinessProps = PhoneNumberBusinessOnyxProps & SubStepProps; const COMPANY_PHONE_NUMBER_KEY = INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_PHONE; const STEP_FIELDS = [COMPANY_PHONE_NUMBER_KEY]; -const validate = (values: FormOnyxValues): FormInputErrors => { +const validate = (values: FormOnyxValues, inputValue: string): FormInputErrors => { const errors = ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); - if (values.companyPhone && !ValidationUtils.isValidUSPhone(values.companyPhone, true)) { + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + if ((values.companyPhone && !ValidationUtils.isValidUSPhone(values.companyPhone, true)) || inputValue.trim() !== inputValue) { errors.companyPhone = 'bankAccount.error.phoneNumber'; } @@ -41,6 +42,12 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum const styles = useThemeStyles(); const defaultCompanyPhoneNumber = reimbursementAccount?.achData?.companyPhone ?? ''; + const [inputValue, setInputValue] = useState(defaultCompanyPhoneNumber); + + const handleInputChange = (newValue: string) => { + setInputValue(newValue); + }; + const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, isEditing, @@ -51,7 +58,7 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum validate(values, inputValue)} onSubmit={handleSubmit} style={[styles.mh5, styles.flexGrow1]} submitButtonStyles={[styles.pb5, styles.mb0]} @@ -68,6 +75,7 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum defaultValue={defaultCompanyPhoneNumber} shouldSaveDraft={!isEditing} containerStyles={[styles.mt6]} + onChangeText={handleInputChange} /> ); From 2fa5415ddd6951a4ffe88c5b2c0ae278cdf60e75 Mon Sep 17 00:00:00 2001 From: RohanSasne Date: Fri, 23 Feb 2024 00:00:54 +0530 Subject: [PATCH 02/10] Set isEditing to true to trim the input --- .../substeps/PhoneNumberBusiness.tsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index 3a851b001ff7..650dd32e069d 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import React from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; @@ -26,11 +26,11 @@ type PhoneNumberBusinessProps = PhoneNumberBusinessOnyxProps & SubStepProps; const COMPANY_PHONE_NUMBER_KEY = INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_PHONE; const STEP_FIELDS = [COMPANY_PHONE_NUMBER_KEY]; -const validate = (values: FormOnyxValues, inputValue: string): FormInputErrors => { +const validate = (values: FormOnyxValues): FormInputErrors => { const errors = ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if ((values.companyPhone && !ValidationUtils.isValidUSPhone(values.companyPhone, true)) || inputValue.trim() !== inputValue) { + if ((values.companyPhone && !ValidationUtils.isValidUSPhone(values.companyPhone, true))) { errors.companyPhone = 'bankAccount.error.phoneNumber'; } @@ -42,15 +42,9 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum const styles = useThemeStyles(); const defaultCompanyPhoneNumber = reimbursementAccount?.achData?.companyPhone ?? ''; - const [inputValue, setInputValue] = useState(defaultCompanyPhoneNumber); - - const handleInputChange = (newValue: string) => { - setInputValue(newValue); - }; - const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, + isEditing: true, onNext, }); @@ -58,7 +52,7 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum validate(values, inputValue)} + validate={validate} onSubmit={handleSubmit} style={[styles.mh5, styles.flexGrow1]} submitButtonStyles={[styles.pb5, styles.mb0]} @@ -75,7 +69,6 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum defaultValue={defaultCompanyPhoneNumber} shouldSaveDraft={!isEditing} containerStyles={[styles.mt6]} - onChangeText={handleInputChange} /> ); From 59830b8f8138d918be3f4d6b1a121d694762857b Mon Sep 17 00:00:00 2001 From: RohanSasne Date: Fri, 23 Feb 2024 00:02:32 +0530 Subject: [PATCH 03/10] Set isEditing to true to trim the input --- .../BusinessInfo/substeps/PhoneNumberBusiness.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index 650dd32e069d..e2746dbab59f 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -29,8 +29,7 @@ const STEP_FIELDS = [COMPANY_PHONE_NUMBER_KEY]; const validate = (values: FormOnyxValues): FormInputErrors => { const errors = ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if ((values.companyPhone && !ValidationUtils.isValidUSPhone(values.companyPhone, true))) { + if (values.companyPhone && !ValidationUtils.isValidUSPhone(values.companyPhone, true)) { errors.companyPhone = 'bankAccount.error.phoneNumber'; } From 1f945a2ac05cd735ce461f357184143df8a09911 Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Wed, 6 Mar 2024 23:42:39 +0530 Subject: [PATCH 04/10] use shouldSaveDraft --- src/hooks/useReimbursementAccountStepFormSubmit.ts | 5 ++++- .../BusinessInfo/substeps/PhoneNumberBusiness.tsx | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hooks/useReimbursementAccountStepFormSubmit.ts b/src/hooks/useReimbursementAccountStepFormSubmit.ts index f3a17447c7d7..6cf1cc077c99 100644 --- a/src/hooks/useReimbursementAccountStepFormSubmit.ts +++ b/src/hooks/useReimbursementAccountStepFormSubmit.ts @@ -8,6 +8,7 @@ import type {SubStepProps} from './useSubStep/types'; type UseReimbursementAccountStepFormSubmitParams = Pick & { formId?: OnyxFormKey; fieldIds: Array>; + shouldSaveDraft?: boolean; }; /** @@ -17,16 +18,18 @@ type UseReimbursementAccountStepFormSubmitParams = Pick) => { - if (isEditing) { + if (isEditing || shouldSaveDraft) { const stepValues = fieldIds.reduce( (acc, key) => ({ ...acc, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index e2746dbab59f..a000d1e067a6 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -43,8 +43,9 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing: true, + isEditing, onNext, + shouldSaveDraft: true, }); return ( From 2b73c75b2c975f2639d8e9b5b59d7a822ee3af82 Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Thu, 7 Mar 2024 00:02:28 +0530 Subject: [PATCH 05/10] Add useCallback dependency --- src/hooks/useReimbursementAccountStepFormSubmit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useReimbursementAccountStepFormSubmit.ts b/src/hooks/useReimbursementAccountStepFormSubmit.ts index 6cf1cc077c99..8f506b8ba127 100644 --- a/src/hooks/useReimbursementAccountStepFormSubmit.ts +++ b/src/hooks/useReimbursementAccountStepFormSubmit.ts @@ -43,6 +43,6 @@ export default function useReimbursementAccountStepFormSubmit({ onNext(); }, - [isEditing, onNext, formId, fieldIds], + [isEditing, onNext, formId, fieldIds, shouldSaveDraft], ); } From f71c96a5a2a549564b0e8cf1f292a019a1ed108a Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Mon, 11 Mar 2024 01:01:24 +0530 Subject: [PATCH 06/10] Final fix for all pages --- src/hooks/useReimbursementAccountStepFormSubmit.ts | 2 +- .../BusinessInfo/substeps/AddressBusiness.tsx | 1 + .../ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx | 1 + .../BusinessInfo/substeps/TaxIdBusiness.tsx | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hooks/useReimbursementAccountStepFormSubmit.ts b/src/hooks/useReimbursementAccountStepFormSubmit.ts index 8f506b8ba127..aa346a8ab5a2 100644 --- a/src/hooks/useReimbursementAccountStepFormSubmit.ts +++ b/src/hooks/useReimbursementAccountStepFormSubmit.ts @@ -29,7 +29,7 @@ export default function useReimbursementAccountStepFormSubmit({ }: UseReimbursementAccountStepFormSubmitParams) { return useCallback( (values: FormOnyxValues) => { - if (isEditing || shouldSaveDraft) { + if (shouldSaveDraft) { const stepValues = fieldIds.reduce( (acc, key) => ({ ...acc, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx index 354620f5e46a..8abeec0cb16a 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx @@ -65,6 +65,7 @@ function AddressBusiness({reimbursementAccount, onNext, isEditing}: AddressBusin fieldIds: STEP_FIELDS, isEditing, onNext, + shouldSaveDraft: true, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx index 8fc637fd24f2..338b9e8f6073 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx @@ -49,6 +49,7 @@ function NameBusiness({reimbursementAccount, onNext, isEditing}: NameBusinessPro fieldIds: STEP_FIELDS, isEditing, onNext, + shouldSaveDraft: true, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx index 46680276e76e..f8177771dd8d 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx @@ -47,6 +47,7 @@ function TaxIdBusiness({reimbursementAccount, onNext, isEditing}: TaxIdBusinessP fieldIds: STEP_FIELDS, isEditing, onNext, + shouldSaveDraft: true, }); return ( From e3cb6abd3c047b3ea8052814378760d9b0ac51e0 Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Mon, 11 Mar 2024 01:26:36 +0530 Subject: [PATCH 07/10] Final fix for all pages --- src/hooks/useReimbursementAccountStepFormSubmit.ts | 8 +++----- .../BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx | 1 - .../BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx | 1 - .../BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx | 1 - .../SocialSecurityNumberUBO.tsx | 1 - .../BusinessInfo/substeps/AddressBusiness.tsx | 2 -- .../BusinessInfo/substeps/IncorporationStateBusiness.tsx | 1 - .../BusinessInfo/substeps/NameBusiness.tsx | 2 -- .../BusinessInfo/substeps/PhoneNumberBusiness.tsx | 2 -- .../BusinessInfo/substeps/TaxIdBusiness.tsx | 2 -- .../BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx | 1 - .../BusinessInfo/substeps/WebsiteBusiness.tsx | 1 - .../PersonalInfo/substeps/Address.tsx | 1 - .../PersonalInfo/substeps/DateOfBirth.tsx | 1 - .../PersonalInfo/substeps/FullName.tsx | 1 - .../PersonalInfo/substeps/SocialSecurityNumber.tsx | 1 - 16 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/hooks/useReimbursementAccountStepFormSubmit.ts b/src/hooks/useReimbursementAccountStepFormSubmit.ts index aa346a8ab5a2..767abd2607db 100644 --- a/src/hooks/useReimbursementAccountStepFormSubmit.ts +++ b/src/hooks/useReimbursementAccountStepFormSubmit.ts @@ -5,7 +5,7 @@ import type {OnyxFormKey} from '@src/ONYXKEYS'; import ONYXKEYS from '@src/ONYXKEYS'; import type {SubStepProps} from './useSubStep/types'; -type UseReimbursementAccountStepFormSubmitParams = Pick & { +type UseReimbursementAccountStepFormSubmitParams = Pick & { formId?: OnyxFormKey; fieldIds: Array>; shouldSaveDraft?: boolean; @@ -15,17 +15,15 @@ type UseReimbursementAccountStepFormSubmitParams = Pick) => { @@ -43,6 +41,6 @@ export default function useReimbursementAccountStepFormSubmit({ onNext(); }, - [isEditing, onNext, formId, fieldIds, shouldSaveDraft], + [onNext, formId, fieldIds, shouldSaveDraft], ); } diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx index 999710310224..3bffb21727d8 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx @@ -59,7 +59,6 @@ function AddressUBO({reimbursementAccountDraft, onNext, isEditing, beneficialOwn const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: stepFields, - isEditing, onNext, }); diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx index be1a0f170665..00a89939c0e4 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx @@ -51,7 +51,6 @@ function DateOfBirthUBO({reimbursementAccountDraft, onNext, isEditing, beneficia const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: [dobInputID], - isEditing, onNext, }); diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx index ccd7104e2276..d7527003b1f7 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx @@ -39,7 +39,6 @@ function LegalNameUBO({reimbursementAccountDraft, onNext, isEditing, beneficialO const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: stepFields, - isEditing, onNext, }); diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx index 3b5710134114..c2ea1d4dbafe 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx @@ -43,7 +43,6 @@ function SocialSecurityNumberUBO({reimbursementAccountDraft, onNext, isEditing, const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: stepFields, - isEditing, onNext, }); diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx index 8abeec0cb16a..7da49062120b 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx @@ -63,9 +63,7 @@ function AddressBusiness({reimbursementAccount, onNext, isEditing}: AddressBusin const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, - shouldSaveDraft: true, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx index b437e6ec05b5..61ab1aade95a 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx @@ -35,7 +35,6 @@ function IncorporationStateBusiness({reimbursementAccount, onNext, isEditing}: I const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, }); diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx index 338b9e8f6073..36c9e7a11e6a 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx @@ -47,9 +47,7 @@ function NameBusiness({reimbursementAccount, onNext, isEditing}: NameBusinessPro const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, - shouldSaveDraft: true, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index a000d1e067a6..e0d2b4c3be4e 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -43,9 +43,7 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, - shouldSaveDraft: true, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx index f8177771dd8d..a6a7c1e00b36 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx @@ -45,9 +45,7 @@ function TaxIdBusiness({reimbursementAccount, onNext, isEditing}: TaxIdBusinessP const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, - shouldSaveDraft: true, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx index f573923bd5c5..48e173f8dde6 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx @@ -35,7 +35,6 @@ function TypeBusiness({reimbursementAccount, onNext, isEditing}: TypeBusinessPro const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, }); diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx index fedb9b29af71..772b5a52aed1 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx @@ -56,7 +56,6 @@ function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, }); diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx index 824ed950bd9f..2c45287028ea 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx @@ -62,7 +62,6 @@ function Address({reimbursementAccount, onNext, isEditing}: AddressProps) { const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, - isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx index 1aa7a083b20d..581d7dc47258 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx @@ -58,7 +58,6 @@ function DateOfBirth({reimbursementAccount, reimbursementAccountDraft, onNext, i const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, - isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx index 412227570365..bf09276573db 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx @@ -52,7 +52,6 @@ function FullName({reimbursementAccount, onNext, isEditing}: FullNameProps) { const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, - isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx index 02407dbce467..a32b07f5ff3a 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx @@ -46,7 +46,6 @@ function SocialSecurityNumber({reimbursementAccount, onNext, isEditing}: SocialS const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, - isEditing, }); return ( From 1425e826e09ee21df0bba751605e3b10aefc8bea Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Mon, 11 Mar 2024 01:40:53 +0530 Subject: [PATCH 08/10] Final fix for all pages --- .../BusinessInfo/substeps/IncorporationDateBusiness.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx index 476d26f9589a..aa969e17ecf2 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx @@ -49,7 +49,6 @@ function IncorporationDateBusiness({reimbursementAccount, reimbursementAccountDr const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - isEditing, onNext, }); From 7c73dc81b455ae0c2b90536e9a381c4244660c30 Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Mon, 11 Mar 2024 16:27:13 +0530 Subject: [PATCH 09/10] add shuldSaveDraft --- src/hooks/useReimbursementAccountStepFormSubmit.ts | 4 ++-- .../BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx | 1 + .../BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx | 1 + .../BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx | 1 + .../SocialSecurityNumberUBO.tsx | 1 + .../BusinessInfo/substeps/AddressBusiness.tsx | 1 + .../BusinessInfo/substeps/IncorporationDateBusiness.tsx | 1 + .../BusinessInfo/substeps/IncorporationStateBusiness.tsx | 1 + .../BusinessInfo/substeps/NameBusiness.tsx | 1 + .../BusinessInfo/substeps/PhoneNumberBusiness.tsx | 2 ++ .../BusinessInfo/substeps/TaxIdBusiness.tsx | 1 + .../BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx | 1 + .../BusinessInfo/substeps/WebsiteBusiness.tsx | 1 + .../ReimbursementAccount/PersonalInfo/substeps/Address.tsx | 1 + .../PersonalInfo/substeps/DateOfBirth.tsx | 1 + .../ReimbursementAccount/PersonalInfo/substeps/FullName.tsx | 1 + .../PersonalInfo/substeps/SocialSecurityNumber.tsx | 1 + 17 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/hooks/useReimbursementAccountStepFormSubmit.ts b/src/hooks/useReimbursementAccountStepFormSubmit.ts index 767abd2607db..98f079dd2447 100644 --- a/src/hooks/useReimbursementAccountStepFormSubmit.ts +++ b/src/hooks/useReimbursementAccountStepFormSubmit.ts @@ -8,7 +8,7 @@ import type {SubStepProps} from './useSubStep/types'; type UseReimbursementAccountStepFormSubmitParams = Pick & { formId?: OnyxFormKey; fieldIds: Array>; - shouldSaveDraft?: boolean; + shouldSaveDraft: boolean; }; /** @@ -23,7 +23,7 @@ export default function useReimbursementAccountStepFormSubmit({ formId = ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, onNext, fieldIds, - shouldSaveDraft = true, + shouldSaveDraft, }: UseReimbursementAccountStepFormSubmitParams) { return useCallback( (values: FormOnyxValues) => { diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx index 3bffb21727d8..b68423115825 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/AddressUBO.tsx @@ -60,6 +60,7 @@ function AddressUBO({reimbursementAccountDraft, onNext, isEditing, beneficialOwn const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: stepFields, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx index 00a89939c0e4..b60b19193dbc 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/DateOfBirthUBO.tsx @@ -52,6 +52,7 @@ function DateOfBirthUBO({reimbursementAccountDraft, onNext, isEditing, beneficia const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: [dobInputID], onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx index d7527003b1f7..0fc7ab10d133 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/LegalNameUBO.tsx @@ -40,6 +40,7 @@ function LegalNameUBO({reimbursementAccountDraft, onNext, isEditing, beneficialO const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: stepFields, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx index c2ea1d4dbafe..7c0c5ac0c057 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/SocialSecurityNumberUBO.tsx @@ -44,6 +44,7 @@ function SocialSecurityNumberUBO({reimbursementAccountDraft, onNext, isEditing, const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: stepFields, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx index 7da49062120b..bd6cf04adab2 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx @@ -64,6 +64,7 @@ function AddressBusiness({reimbursementAccount, onNext, isEditing}: AddressBusin const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx index aa969e17ecf2..1f6b341cb261 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx @@ -50,6 +50,7 @@ function IncorporationDateBusiness({reimbursementAccount, reimbursementAccountDr const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx index 61ab1aade95a..02d932cf990e 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx @@ -36,6 +36,7 @@ function IncorporationStateBusiness({reimbursementAccount, onNext, isEditing}: I const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx index 36c9e7a11e6a..377fbf9782ae 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx @@ -48,6 +48,7 @@ function NameBusiness({reimbursementAccount, onNext, isEditing}: NameBusinessPro const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index e0d2b4c3be4e..6f77d64b28b7 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -44,6 +44,8 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + // We want to remove sanitize user input i.e. remove leading and trailing whitespaces + shouldSaveDraft: true, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx index a6a7c1e00b36..cabf0fc01576 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx @@ -46,6 +46,7 @@ function TaxIdBusiness({reimbursementAccount, onNext, isEditing}: TaxIdBusinessP const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx index 48e173f8dde6..0ee629ae5e21 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness/TypeBusiness.tsx @@ -36,6 +36,7 @@ function TypeBusiness({reimbursementAccount, onNext, isEditing}: TypeBusinessPro const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx index 772b5a52aed1..0988b861e78f 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx @@ -57,6 +57,7 @@ function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); useEffect(() => { diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx index 2c45287028ea..712661510b7d 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Address.tsx @@ -62,6 +62,7 @@ function Address({reimbursementAccount, onNext, isEditing}: AddressProps) { const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx index 581d7dc47258..b02a56403641 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/DateOfBirth.tsx @@ -58,6 +58,7 @@ function DateOfBirth({reimbursementAccount, reimbursementAccountDraft, onNext, i const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx index bf09276573db..1d225c1c32f2 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/FullName.tsx @@ -52,6 +52,7 @@ function FullName({reimbursementAccount, onNext, isEditing}: FullNameProps) { const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx index a32b07f5ff3a..e647fd768fb1 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/SocialSecurityNumber.tsx @@ -46,6 +46,7 @@ function SocialSecurityNumber({reimbursementAccount, onNext, isEditing}: SocialS const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, + shouldSaveDraft: isEditing, }); return ( From 7c2e74d6367e14bdc401f340d33ba87cbf86a871 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Wed, 13 Mar 2024 18:39:19 +0530 Subject: [PATCH 10/10] Update PhoneNumberBusiness.tsx --- .../BusinessInfo/substeps/PhoneNumberBusiness.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index 6f77d64b28b7..018922610080 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -44,7 +44,7 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, onNext, - // We want to remove sanitize user input i.e. remove leading and trailing whitespaces + // During draft saving, the phone number is sanitized (i.e. leading and trailing whitespace is removed) shouldSaveDraft: true, });