-
Notifications
You must be signed in to change notification settings - Fork 18
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 the problem of the document field (CPF) blocking even with the empty document. #104
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,65 +5,66 @@ import RuleFieldShape from './RuleFieldShape' | |
import ProfileFieldShape from './ProfileFieldShape' | ||
|
||
class ProfileField extends Component { | ||
componentDidUpdate() { | ||
const { field, data, onFieldUpdate } = this.props | ||
if (data.focus && this.el) { | ||
this.el.focus() | ||
onFieldUpdate({ [field.name]: { ...data, focus: false } }) | ||
componentDidUpdate() { | ||
const { field, data, onFieldUpdate } = this.props | ||
if (data.focus && this.el) { | ||
this.el.focus() | ||
onFieldUpdate({ | ||
[field.name]: {...data, focus: false } }) | ||
} | ||
} | ||
} | ||
|
||
handleChange = e => { | ||
const { field, data, onFieldUpdate } = this.props | ||
const { value } = e.target | ||
handleChange = e => { | ||
const { field, data, onFieldUpdate } = this.props | ||
const { value } = e.target | ||
|
||
const error = data.touched ? applyValidation(field, value) : null | ||
const maskedValue = applyMask(field, value) | ||
const error = data.touched ? applyValidation(field, value) : null | ||
const maskedValue = applyMask(field, value) | ||
|
||
onFieldUpdate({ [field.name]: { ...data, value: maskedValue, error } }) | ||
} | ||
|
||
handleBlur = () => { | ||
const { field, data, onFieldUpdate } = this.props | ||
const error = applyValidation(field, data.value) | ||
onFieldUpdate({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that there is a problem with the .editorconfig. It has changed from spaces to tabs, it makes harder to understand what was the change... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has the spacing been changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @salesfelipe Correct the spacing leaving it as it was in the master. Commited |
||
[field.name]: {...data, value: maskedValue, error } }) | ||
} | ||
|
||
onFieldUpdate({ [field.name]: { ...data, touched: true, error } }) | ||
} | ||
handleBlur = () => { | ||
const { field, data, onFieldUpdate } = this.props | ||
const error = applyValidation(field, data.value) | ||
|
||
inputRef = el => { | ||
this.el = el | ||
} | ||
onFieldUpdate({ | ||
[field.name]: {...data, touched: true, error } }) | ||
} | ||
|
||
render() { | ||
const { field, data, options, Input, userProfile, blockDocument } = this.props | ||
inputRef = el => { | ||
this.el = el | ||
} | ||
|
||
if(blockDocument && field.name === 'document' && userProfile['document'].value !== null){ | ||
field.disabled = true | ||
render() { | ||
const { field, data, options, Input, userProfile, blockDocument } = this.props | ||
if (blockDocument && field.name === 'document' && (userProfile['document'].value !== null && userProfile['document'].value !== "")) { | ||
field.disabled = true | ||
} | ||
return ( < | ||
Input field = { field } | ||
data = { data } | ||
options = { options } | ||
inputRef = { this.inputRef } | ||
onChange = { this.handleChange } | ||
onBlur = { this.handleBlur } | ||
/> | ||
) | ||
} | ||
return ( | ||
<Input | ||
field={field} | ||
data={data} | ||
options={options} | ||
inputRef={this.inputRef} | ||
onChange={this.handleChange} | ||
onBlur={this.handleBlur} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
ProfileField.propTypes = { | ||
/** Rules for the field this component represents */ | ||
field: RuleFieldShape.isRequired, | ||
/** Data to be displayed by this component */ | ||
data: ProfileFieldShape.isRequired, | ||
/** Additional options to modify this input */ | ||
options: PropTypes.object, | ||
/** Function to be called when data changes */ | ||
onFieldUpdate: PropTypes.func.isRequired, | ||
/** Component to be used as input for the field */ | ||
Input: PropTypes.func.isRequired, | ||
/** Rules for the field this component represents */ | ||
field: RuleFieldShape.isRequired, | ||
/** Data to be displayed by this component */ | ||
data: ProfileFieldShape.isRequired, | ||
/** Additional options to modify this input */ | ||
options: PropTypes.object, | ||
/** Function to be called when data changes */ | ||
onFieldUpdate: PropTypes.func.isRequired, | ||
/** Component to be used as input for the field */ | ||
Input: PropTypes.func.isRequired, | ||
} | ||
|
||
export default ProfileField | ||
export default ProfileField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a changelog conflict