Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve Document Field Problems with the blockDocument property #143

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions react/ProfileField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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 (
<Input
field={field}
data={data}
data={data}
options={options}
inputRef={this.inputRef}
onChange={this.handleChange}
Expand Down
9 changes: 6 additions & 3 deletions react/__tests__/ProfileField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ describe('ProfileField', () => {
)

// Act
maskWrapper.instance().handleChange({ target: { value: '123456789' } })
maskWrapper.instance().handleChange({ target: { value: '123456789' , changing: true } })

// Assert
expect(mockChange).toHaveBeenCalledWith({
[maskField.name]: {
...mockData,
value: '-123456789-',
error: null,
changing: true,
},
})
})
Expand All @@ -81,14 +82,15 @@ describe('ProfileField', () => {
)

// Act
valWrapper.instance().handleChange({ target: { value: '' } })
valWrapper.instance().handleChange({ target: { value: '' , changing: true } })

// Assert
expect(mockChange).toHaveBeenCalledWith({
[valField.name]: {
...valData,
value: '',
error: 'EMPTY_FIELD',
changing: true,
},
})
})
Expand All @@ -107,14 +109,15 @@ describe('ProfileField', () => {
)

// Act
valWrapper.instance().handleChange({ target: { value: '' } })
valWrapper.instance().handleChange({ target: { value: '' , changing: true } })

// Assert
expect(mockChange).toHaveBeenCalledWith({
[valField.name]: {
...valData,
value: '',
error: null,
changing: true,
},
})
})
Expand Down