1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useEffect , useRef , useState } from 'react' ;
22import { View } from 'react-native' ;
33import Button from '@components/Button' ;
44import DotIndicatorMessage from '@components/DotIndicatorMessage' ;
55import FormProvider from '@components/Form/FormProvider' ;
66import InputWrapper from '@components/Form/InputWrapper' ;
7- import type { FormInputErrors , FormOnyxKeys , FormOnyxValues } from '@components/Form/types' ;
7+ import type { FormInputErrors , FormOnyxKeys , FormOnyxValues , FormRef } from '@components/Form/types' ;
88import Text from '@components/Text' ;
99import UploadFile from '@components/UploadFile' ;
1010import useLocalize from '@hooks/useLocalize' ;
@@ -17,7 +17,7 @@ import {getFieldRequiredErrors} from '@libs/ValidationUtils';
1717import getCurrencyForNonUSDBankAccount from '@pages/ReimbursementAccount/NonUSD/utils/getCurrencyForNonUSDBankAccount' ;
1818import getNeededDocumentsStatusForSignerInfo from '@pages/ReimbursementAccount/utils/getNeededDocumentsStatusForSignerInfo' ;
1919import WhyLink from '@pages/ReimbursementAccount/WhyLink' ;
20- import { clearErrorFields , setDraftValues , setErrorFields } from '@userActions/FormActions' ;
20+ import { clearErrorFields , clearErrors , setDraftValues , setErrorFields } from '@userActions/FormActions' ;
2121import { openExternalLink } from '@userActions/Link' ;
2222import CONST from '@src/CONST' ;
2323import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -50,6 +50,8 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
5050 [ CODICE_FISCALE ] : Array . isArray ( reimbursementAccountDraft ?. [ CODICE_FISCALE ] ) ? ( reimbursementAccountDraft ?. [ CODICE_FISCALE ] ?? [ ] ) : [ ] ,
5151 } ;
5252
53+ const formRef = useRef < FormRef | null > ( null ) ;
54+
5355 const [ uploadedIDs , setUploadedID ] = useState < FileObject [ ] > ( defaultValues [ COPY_OF_ID ] ) ;
5456 const [ uploadedProofsOfAddress , setUploadedProofOfAddress ] = useState < FileObject [ ] > ( defaultValues [ ADDRESS_PROOF ] ) ;
5557 const [ uploadedProofsOfDirectors , setUploadedProofsOfDirectors ] = useState < FileObject [ ] > ( defaultValues [ PROOF_OF_DIRECTORS ] ) ;
@@ -97,6 +99,8 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
9799 return ;
98100 }
99101
102+ formRef . current ?. resetFormFieldError ( inputID ) ;
103+ clearErrors ( ONYXKEYS . FORMS . REIMBURSEMENT_ACCOUNT_FORM ) ;
100104 setErrorFields ( ONYXKEYS . FORMS . REIMBURSEMENT_ACCOUNT_FORM , { [ inputID ] : { onUpload : error } } ) ;
101105 } ;
102106
@@ -108,6 +112,7 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
108112
109113 return (
110114 < FormProvider
115+ ref = { formRef }
111116 formID = { ONYXKEYS . FORMS . REIMBURSEMENT_ACCOUNT_FORM }
112117 submitButtonText = { translate ( isEditing ? 'common.confirm' : 'common.next' ) }
113118 onSubmit = { handleSubmitWithDownload }
@@ -131,13 +136,14 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
131136 onRemove = { ( fileName ) => {
132137 handleRemoveFile ( fileName , uploadedIDs , COPY_OF_ID , setUploadedID ) ;
133138 } }
134- acceptedFileTypes = { [ ...CONST . NON_USD_BANK_ACCOUNT . ALLOWED_FILE_TYPES ] }
139+ acceptedFileTypes = { [ ...CONST . CORPAY_DOCUMENT . ALLOWED_FILE_TYPES ] }
135140 value = { uploadedIDs }
136141 inputID = { COPY_OF_ID }
137142 setError = { ( error ) => {
138143 setUploadError ( error , COPY_OF_ID ) ;
139144 } }
140- fileLimit = { CONST . NON_USD_BANK_ACCOUNT . FILE_LIMIT }
145+ fileLimit = { CONST . CORPAY_DOCUMENT . FILE_LIMIT }
146+ maxFileSize = { CONST . CORPAY_DOCUMENT . MAX_FILE_SIZE }
141147 />
142148 < Text style = { [ styles . mutedTextLabel , styles . mt6 ] } > { translate ( 'ownershipInfoStep.copyOfIDDescription' ) } </ Text >
143149 { ( isDocumentNeededStatus . isAddressProofNeeded ||
@@ -159,13 +165,14 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
159165 onRemove = { ( fileName ) => {
160166 handleRemoveFile ( fileName , uploadedProofsOfAddress , ADDRESS_PROOF , setUploadedProofOfAddress ) ;
161167 } }
162- acceptedFileTypes = { [ ...CONST . NON_USD_BANK_ACCOUNT . ALLOWED_FILE_TYPES ] }
168+ acceptedFileTypes = { [ ...CONST . CORPAY_DOCUMENT . ALLOWED_FILE_TYPES ] }
163169 value = { uploadedProofsOfAddress }
164170 inputID = { ADDRESS_PROOF }
165171 setError = { ( error ) => {
166172 setUploadError ( error , ADDRESS_PROOF ) ;
167173 } }
168- fileLimit = { CONST . NON_USD_BANK_ACCOUNT . FILE_LIMIT }
174+ fileLimit = { CONST . CORPAY_DOCUMENT . FILE_LIMIT }
175+ maxFileSize = { CONST . CORPAY_DOCUMENT . MAX_FILE_SIZE }
169176 />
170177 < Text style = { [ styles . mutedTextLabel , styles . mt6 ] } > { translate ( 'ownershipInfoStep.proofOfAddressDescription' ) } </ Text >
171178 { ( isDocumentNeededStatus . isProofOfDirectorsNeeded || isDocumentNeededStatus . isCodiceFiscaleNeeded || isDocumentNeededStatus . isPRDAndFSGNeeded ) && (
@@ -186,13 +193,14 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
186193 onRemove = { ( fileName ) => {
187194 handleRemoveFile ( fileName , uploadedProofsOfDirectors , PROOF_OF_DIRECTORS , setUploadedProofsOfDirectors ) ;
188195 } }
189- acceptedFileTypes = { [ ...CONST . NON_USD_BANK_ACCOUNT . ALLOWED_FILE_TYPES ] }
196+ acceptedFileTypes = { [ ...CONST . CORPAY_DOCUMENT . ALLOWED_FILE_TYPES ] }
190197 value = { uploadedProofsOfDirectors }
191198 inputID = { PROOF_OF_DIRECTORS }
192199 setError = { ( error ) => {
193200 setUploadError ( error , PROOF_OF_DIRECTORS ) ;
194201 } }
195- fileLimit = { CONST . NON_USD_BANK_ACCOUNT . FILE_LIMIT }
202+ fileLimit = { CONST . CORPAY_DOCUMENT . FILE_LIMIT }
203+ maxFileSize = { CONST . CORPAY_DOCUMENT . MAX_FILE_SIZE }
196204 />
197205 < Text style = { [ styles . mutedTextLabel , styles . mt6 ] } > { translate ( 'signerInfoStep.proofOfDirectorsDescription' ) } </ Text >
198206 { ( isDocumentNeededStatus . isCodiceFiscaleNeeded || isDocumentNeededStatus . isPRDAndFSGNeeded ) && < View style = { [ styles . sectionDividerLine , styles . mt6 , styles . mb6 ] } /> }
@@ -211,13 +219,14 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
211219 onRemove = { ( fileName ) => {
212220 handleRemoveFile ( fileName , uploadedCodiceFiscale , CODICE_FISCALE , setUploadedCodiceFiscale ) ;
213221 } }
214- acceptedFileTypes = { [ ...CONST . NON_USD_BANK_ACCOUNT . ALLOWED_FILE_TYPES ] }
222+ acceptedFileTypes = { [ ...CONST . CORPAY_DOCUMENT . ALLOWED_FILE_TYPES ] }
215223 value = { uploadedCodiceFiscale }
216224 inputID = { CODICE_FISCALE }
217225 setError = { ( error ) => {
218226 setUploadError ( error , CODICE_FISCALE ) ;
219227 } }
220- fileLimit = { CONST . NON_USD_BANK_ACCOUNT . FILE_LIMIT }
228+ fileLimit = { CONST . CORPAY_DOCUMENT . FILE_LIMIT }
229+ maxFileSize = { CONST . CORPAY_DOCUMENT . MAX_FILE_SIZE }
221230 />
222231 < Text style = { [ styles . mutedTextLabel , styles . mt6 ] } > { translate ( 'signerInfoStep.codiceFiscaleDescription' ) } </ Text >
223232 { isDocumentNeededStatus . isPRDAndFSGNeeded && < View style = { [ styles . sectionDividerLine , styles . mt6 , styles . mb6 ] } /> }
0 commit comments