diff --git a/CHANGELOG.md b/CHANGELOG.md index f9f39b5c..4b43cec0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Verification if the user's document is filled with the blockDocument + ## [3.10.0] - 2021-11-04 ### Added diff --git a/react/ProfileField.js b/react/ProfileField.js index 484e3406..8f050c5f 100644 --- a/react/ProfileField.js +++ b/react/ProfileField.js @@ -20,7 +20,7 @@ class ProfileField extends Component { const error = data.touched ? applyValidation(field, value) : null const maskedValue = applyMask(field, value) - onFieldUpdate({ [field.name]: { ...data, value: maskedValue, error } }) + onFieldUpdate({ [field.name]: { ...data, value: maskedValue, error, changing: true } }) } handleBlur = () => { @@ -36,14 +36,13 @@ class ProfileField extends Component { render() { const { field, data, options, Input, userProfile, blockDocument } = this.props - - if(blockDocument && field.name === 'document' && userProfile['document'].value !== null){ - field.disabled = true + if(blockDocument && field.name === 'document' && userProfile.document.value && !userProfile.document.changing) { + field.disabled = true } return ( { ) // Act - maskWrapper.instance().handleChange({ target: { value: '123456789' } }) + maskWrapper.instance().handleChange({ target: { value: '123456789' , changing: true } }) // Assert expect(mockChange).toHaveBeenCalledWith({ @@ -63,6 +63,7 @@ describe('ProfileField', () => { ...mockData, value: '-123456789-', error: null, + changing: true, }, }) }) @@ -81,7 +82,7 @@ describe('ProfileField', () => { ) // Act - valWrapper.instance().handleChange({ target: { value: '' } }) + valWrapper.instance().handleChange({ target: { value: '' , changing: true } }) // Assert expect(mockChange).toHaveBeenCalledWith({ @@ -89,6 +90,7 @@ describe('ProfileField', () => { ...valData, value: '', error: 'EMPTY_FIELD', + changing: true, }, }) }) @@ -107,7 +109,7 @@ describe('ProfileField', () => { ) // Act - valWrapper.instance().handleChange({ target: { value: '' } }) + valWrapper.instance().handleChange({ target: { value: '' , changing: true } }) // Assert expect(mockChange).toHaveBeenCalledWith({ @@ -115,6 +117,7 @@ describe('ProfileField', () => { ...valData, value: '', error: null, + changing: true, }, }) })