From 6035ade67ad39e9abec9f12999c9807b6e7acccd Mon Sep 17 00:00:00 2001 From: "jailson.damasceno" Date: Thu, 18 Mar 2021 12:31:52 -0300 Subject: [PATCH 1/2] Farmating --- CHANGELOG.md | 2 +- react/ProfileField.js | 97 ++++++++++++++++++++++--------------------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fa1a6d8..45dcc4c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] - +- Added verification if the user's document is empty not only null - Added prop `blockDocument` to Enables or disables editing the document field in my account ## [2.9.3] - 2021-01-11 diff --git a/react/ProfileField.js b/react/ProfileField.js index f1d8e393..5edb4773 100644 --- a/react/ProfileField.js +++ b/react/ProfileField.js @@ -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({ + [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 ( - - ) - } } 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 \ No newline at end of file From d2790e1f1383c3e1b21e6a48a57bab728dae53a7 Mon Sep 17 00:00:00 2001 From: "jailson.damasceno" Date: Wed, 7 Apr 2021 10:54:43 -0300 Subject: [PATCH 2/2] Fixing code spaces tabulation --- react/ProfileField.js | 74 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/react/ProfileField.js b/react/ProfileField.js index 5edb4773..f7a04503 100644 --- a/react/ProfileField.js +++ b/react/ProfileField.js @@ -5,53 +5,51 @@ 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 } }) - } + onFieldUpdate({ [field.name]: {...data, value: maskedValue, error } }) +} - handleBlur = () => { - const { field, data, onFieldUpdate } = this.props - const error = applyValidation(field, data.value) +handleBlur = () => { + const { field, data, onFieldUpdate } = this.props + const error = applyValidation(field, data.value) - onFieldUpdate({ - [field.name]: {...data, touched: true, error } }) - } + onFieldUpdate({ [field.name]: {...data, touched: true, error } }) +} - inputRef = el => { - this.el = el - } +inputRef = el => { + this.el = el +} - 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 } - /> - ) +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 } + /> + ) +} } ProfileField.propTypes = {