diff --git a/actions/questionnaireActions.js b/actions/questionnaireActions.js index 174d1be..315da7a 100644 --- a/actions/questionnaireActions.js +++ b/actions/questionnaireActions.js @@ -180,7 +180,7 @@ export const getQuestionnaire = ({ dispatch, id }) => { console.log("error"); console.error(error); - + reject(); }); } diff --git a/actions/suggestsActions.js b/actions/suggestsActions.js index bb1fe8c..c987a1e 100644 --- a/actions/suggestsActions.js +++ b/actions/suggestsActions.js @@ -81,4 +81,25 @@ export const getSuggests = (type, payload) => reject(); }); }); -} \ No newline at end of file +} + +export const checkDocumentData = (payload) => +{ + return new Promise((resolve, reject) => + { + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/suggests/document/check`, payload, { + withCredentials: true, + }) + .then((response) => + { + resolve(response.data); + }) + .catch((error) => + { + console.log("error"); + console.error(error); + + reject(); + }); + }); +} diff --git a/components/questionnaire/AddressSuggests.js b/components/questionnaire/AddressSuggests.js index d45ace9..fd1258f 100644 --- a/components/questionnaire/AddressSuggests.js +++ b/components/questionnaire/AddressSuggests.js @@ -61,10 +61,11 @@ export default class AddressSuggests extends React.Component const { fias, focused } = this.state; const { onChange } = this.props; - this.setState({ focused: false }, () => + onChange({ name: value, fias_id: fias[value] }); + setTimeout(() => { - onChange({ name: value, fias_id: fias[value] }); - }); + this.setState({ focused: false }); + }, 100); } _handle_onFocus = (event) => diff --git a/components/questionnaire/DocumentIssuerSuggestsInput.js b/components/questionnaire/DocumentIssuerSuggestsInput.js index 0bbcf38..61d1d28 100644 --- a/components/questionnaire/DocumentIssuerSuggestsInput.js +++ b/components/questionnaire/DocumentIssuerSuggestsInput.js @@ -81,10 +81,11 @@ export default class DocumentIssuerSuggestsInput extends React.Component console.log("DocumentIssuerSuggestsInput", "_handle_onSelect", { option }); const { onChange } = this.props; - this.setState({ focused: false }, () => + onChange(option); + setTimeout(() => { - onChange(option); - }); + this.setState({ focused: false }); + }, 100); } _handle_onFocus = () => @@ -187,11 +188,17 @@ export default class DocumentIssuerSuggestsInput extends React.Component disabled={ disabled } /> { focused && options.length > 0 && ( -
+
{ options.map((option, index) => ( -
this._handle_onSelect(option) }>{ option.value }
+
{ event.preventDefault(); this._handle_onSelect(option); } } + onTouchStart={ (event) => { event.preventDefault(); this._handle_onSelect(option); } } + >{ option.value }
)) }
diff --git a/components/questionnaire/SuggestsInput.js b/components/questionnaire/SuggestsInput.js index 27dee14..cec1065 100644 --- a/components/questionnaire/SuggestsInput.js +++ b/components/questionnaire/SuggestsInput.js @@ -69,10 +69,12 @@ export default class SuggestsInput extends React.Component const { onChange } = this.props; onChange(value); - this.setState({ focused: true }, () => + this._getValue(value); + + setTimeout(() => { - this._getValue(value); - }); + this.setState({ focused: false }); + }, 100); } _handle_onSelect = (value) => diff --git a/components/questionnaire/forms/Form_1_Main/index.js b/components/questionnaire/forms/Form_1_Main/index.js index e01ec04..e9f6433 100644 --- a/components/questionnaire/forms/Form_1_Main/index.js +++ b/components/questionnaire/forms/Form_1_Main/index.js @@ -94,10 +94,20 @@ class Form_1_Main extends QuestionnaireForm for(let i in check) { - if(main[check[i]] === "") + if(check[i] === "telephone") { - errors.push(`main.${ check[i] }`); + if(main.telephone === "" || main.telephone === null || isNaN(parseInt(main.telephone.replace(/[^\d]+/g, ''), 10)) || parseInt(main.telephone.replace(/[^\d]+/g, ''), 10).toString().length < 11) + { + errors.push(`main.telephone`); + } } + else + { + if(main[check[i]] === null || main[check[i]] === "") + { + errors.push(`main.${ check[i] }`); + } + } } if(main.websiteurl !== null && main.websiteurl !== "") @@ -112,7 +122,10 @@ class Form_1_Main extends QuestionnaireForm this.setState({ errors }, () => { window.scroll(0, 0); - this.ref_submit.current.click(); + if(errors.length === 0) + { + this.ref_submit.current.click(); + } }); } @@ -276,7 +289,7 @@ class Form_1_Main extends QuestionnaireForm placeholder="Укажите сумму" decimalSeparator="." groupSeparator=" " - suffix=" ₽" + //suffix=" ₽" maxLength={ 12 } onValueChange={ (value, name) => { this._removeError(name); this._handle_onTextFieldChange(name, value); } } required={ true } diff --git a/components/questionnaire/forms/Form_3_Signer/index.js b/components/questionnaire/forms/Form_3_Signer/index.js index 2421831..2a2b437 100644 --- a/components/questionnaire/forms/Form_3_Signer/index.js +++ b/components/questionnaire/forms/Form_3_Signer/index.js @@ -26,7 +26,7 @@ import AddressSuggests from "../../AddressSuggests"; import InputMask from 'react-input-mask'; import SuggestsInput from "../../SuggestsInput"; import { getCitizenshipTitleByCode } from "../../../../utils/citizenship"; -import { removeAttachmentFiles, saveQuestionnaire, getSuggests } from "../../../../actions"; +import { removeAttachmentFiles, saveQuestionnaire, getSuggests, checkDocumentData } from "../../../../actions"; import DocumentIssuerSuggestsInput from "../../DocumentIssuerSuggestsInput"; import FormMessage from "../FormMessage"; @@ -246,6 +246,7 @@ class Form_3_Signer extends QuestionnaireForm const { head_person } = this.state; const indefinite = !head_person.evo_indefinite ? true : false; this._handle_onCheckboxFieldChange("head_person.evo_indefinite", indefinite); + this._removeError("head_person.evo_credentials_dateend"); if(!indefinite) { @@ -322,206 +323,238 @@ class Form_3_Signer extends QuestionnaireForm _handle_onNextPage = (event) => { event.preventDefault(); - - const errors = []; - const { main, head_person, signatory_person, - delegation_files, head_person_files, signatory_person_files, signatory_corporate_files, - } = this.state; - - const head_person_check = [ - "lastname", - "firstname", - "jobtitle", - "email", - "identity_document.seria", - "identity_document.docnumber", - "identity_document.issuedate", - "identity_document.placebirth", - "identity_document.citizenship_code", - "identity_document.registration_address.name", - "evo_assignment_date", - ]; - - if(parseInt(_get(head_person, "identity_document.doctype"), 10) === 100000000) + this.setState({ loading: true }, async () => { - head_person_check.push("identity_document.code"); - head_person_check.push("identity_document.issueby"); - } + const errors = []; + const { main, head_person, signatory_person, + delegation_files, head_person_files, signatory_person_files, signatory_corporate_files, + } = this.state; - for(let i in head_person_check) - { - const v = _get(head_person, head_person_check[i]); - - if(v === "" || v === null) - { - errors.push(`head_person.${ head_person_check[i] }`); - } - } - - if(head_person.evo_assignment_date !== undefined && head_person.evo_assignment_date !== null && head_person.evo_assignment_date !== "") - { - try - { - const date = moment(head_person.evo_assignment_date); - const today = moment(); - - if(date > today) - { - errors.push(`head_person.evo_assignment_date`); - errors.push(`head_person.evo_assignment_date_invalid`); - } - } - catch(e) - { - errors.push(`head_person.evo_assignment_date`); - errors.push(`head_person.evo_assignment_date_invalid`); - } - } - - if(!head_person.evo_indefinite) - { - if(head_person.evo_credentials_dateend === "") - { - errors.push(`head_person.evo_credentials_dateend`); - } - - if(head_person.evo_credentials_dateend !== undefined && head_person.evo_credentials_dateend !== null && head_person.evo_credentials_dateend !== "") - { - try - { - const date = moment(head_person.evo_credentials_dateend); - const today = moment(); - - if(date < today) - { - errors.push(`head_person.evo_credentials_dateend`); - errors.push(`head_person.evo_credentials_dateend_invalid`); - } - } - catch(e) - { - errors.push(`head_person.evo_credentials_dateend`); - errors.push(`head_person.evo_credentials_dateend_invalid`); - } - } - } - - if(head_person.telephone === "" || head_person.telephone === null || isNaN(parseInt(head_person.telephone.replace(/[^\d]+/g, ''), 10)) || parseInt(head_person.telephone.replace(/[^\d]+/g, ''), 10).toString().length < 11) - { - errors.push(`head_person.telephone`); - } - - const email_regex = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/); - if(!email_regex.test(head_person.email)) - { - errors.push(`head_person.email`); - } - - //переданы - if(signatory_person.delegation_agreement) - { - const main_check = [ - "individual_executive_inn", - "individual_executive_kpp", - "individual_executive_oop", - "individual_executive_docnum", - "individual_executive_docdate", - ]; - - for(let i in main_check) - { - let v = _get(main, main_check[i]); - - if(main_check[i] === "individual_executive_inn") - { - if(!is_valid_inn(v.replace(/[^\d]+/g, ''))) - { - errors.push(`main.individual_executive_inn`); - } - } - else - { - if(v === "" || v === null) - { - errors.push(`main.${ main_check[i] }`); - } - } - } - - if(delegation_files.length === 0) { errors.push(`delegation_files`); } - } - - //иной подписант - if(signatory_person.not_head_person) - { - const signatory_person_check = [ + const head_person_check = [ "lastname", "firstname", "jobtitle", - "signer_rule_basic", "email", "identity_document.seria", "identity_document.docnumber", "identity_document.issuedate", "identity_document.placebirth", - "identity_document.citizenship.code", + "identity_document.citizenship_code", "identity_document.registration_address.name", + "evo_assignment_date", ]; - if(parseInt(_get(signatory_person, "identity_document.doctype"), 10) === 100000000) + if(parseInt(_get(head_person, "identity_document.doctype"), 10) === 100000000) { - signatory_person_check.push("identity_document.code"); - signatory_person_check.push("identity_document.issueby"); + head_person_check.push("identity_document.code"); + head_person_check.push("identity_document.issueby"); } - if(parseInt(signatory_person.signer_rule_basic, 10) === 100000003) + for(let i in head_person_check) { - signatory_person_check.push("signer_rule_basic_add"); - } - - if(signatory_person.telephone === "" || signatory_person.telephone === null || isNaN(parseInt(signatory_person.telephone.replace(/[^\d]+/g, ''), 10)) || parseInt(signatory_person.telephone.replace(/[^\d]+/g, ''), 10).toString().length < 11) - { - errors.push(`signatory_person.telephone`); - } - - const email_regex = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/); - if(!email_regex.test(signatory_person.email)) - { - errors.push(`signatory_person.email`); - } - - if(signatory_person_files.length === 0) { errors.push(`signatory_person_files`); } - - if(parseInt(signatory_person.signer_rule_basic, 10) === 100000000 || parseInt(signatory_person.signer_rule_basic, 10) === 100000003) - { - signatory_person_check.push("docdate"); - signatory_person_check.push("docnumber"); - - if(signatory_corporate_files.length === 0) { errors.push(`signatory_corporate_files`); } - } - - for(let i in signatory_person_check) - { - let v = _get(signatory_person, signatory_person_check[i]); + const v = _get(head_person, head_person_check[i]); if(v === "" || v === null) { - errors.push(`signatory_person.${ signatory_person_check[i] }`); + errors.push(`head_person.${ head_person_check[i] }`); } } - } - if(head_person_files.length === 0) { errors.push(`head_person_files`); } - - this.setState({ errors }, () => - { - console.log("_handle_onNextPage", { errors }); - - window.scroll(0, 0); - if(errors.length === 0) + if(head_person.evo_assignment_date !== undefined && head_person.evo_assignment_date !== null && head_person.evo_assignment_date !== "") { - this.ref_submit.current.click(); + try + { + const date = moment(head_person.evo_assignment_date); + const today = moment(); + + if(date > today) + { + errors.push(`head_person.evo_assignment_date`); + errors.push(`head_person.evo_assignment_date_invalid`); + } + } + catch(e) + { + errors.push(`head_person.evo_assignment_date`); + errors.push(`head_person.evo_assignment_date_invalid`); + } } + + if(!head_person.evo_indefinite) + { + if(head_person.evo_credentials_dateend === undefined || head_person.evo_credentials_dateend === null || head_person.evo_credentials_dateend === "") + { + errors.push(`head_person.evo_credentials_dateend`); + } + + if(head_person.evo_credentials_dateend !== undefined && head_person.evo_credentials_dateend !== null && head_person.evo_credentials_dateend !== "") + { + try + { + const date = moment(head_person.evo_credentials_dateend); + const today = moment(); + + if(date < today) + { + errors.push(`head_person.evo_credentials_dateend`); + errors.push(`head_person.evo_credentials_dateend_invalid`); + } + } + catch(e) + { + errors.push(`head_person.evo_credentials_dateend`); + errors.push(`head_person.evo_credentials_dateend_invalid`); + } + } + } + + if(head_person.telephone === "" || head_person.telephone === null || isNaN(parseInt(head_person.telephone.replace(/[^\d]+/g, ''), 10)) || parseInt(head_person.telephone.replace(/[^\d]+/g, ''), 10).toString().length < 11) + { + errors.push(`head_person.telephone`); + } + + const email_regex = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/); + if(!email_regex.test(head_person.email)) + { + errors.push(`head_person.email`); + } + + //8004 + //930118 + if(parseInt(_get(head_person, "identity_document.doctype"), 10) === 100000000 && errors.indexOf("head_persor.identity_document.seria") < 0 && errors.indexOf("head_persor.identity_document.docnumber") < 0) + { + const head_person_document_check_response = await checkDocumentData({ + seria: head_person.identity_document.seria, + number: head_person.identity_document.docnumber, + }); + + if(head_person_document_check_response[0] !== undefined && head_person_document_check_response[0].qc !== 0) + { + errors.push(`head_person.identity_document.invalid`); + errors.push(`head_person.identity_document.seria`); + errors.push(`head_person.identity_document.docnumber`); + } + } + + //переданы + if(signatory_person.delegation_agreement) + { + const main_check = [ + "individual_executive_inn", + "individual_executive_kpp", + "individual_executive_oop", + "individual_executive_docnum", + "individual_executive_docdate", + ]; + + for(let i in main_check) + { + let v = _get(main, main_check[i]); + + if(main_check[i] === "individual_executive_inn") + { + if(!is_valid_inn(v.replace(/[^\d]+/g, ''))) + { + errors.push(`main.individual_executive_inn`); + } + } + else + { + if(v === "" || v === null) + { + errors.push(`main.${ main_check[i] }`); + } + } + } + + if(delegation_files.length === 0) { errors.push(`delegation_files`); } + } + + //иной подписант + if(signatory_person.not_head_person) + { + const signatory_person_check = [ + "lastname", + "firstname", + "jobtitle", + "signer_rule_basic", + "email", + "identity_document.seria", + "identity_document.docnumber", + "identity_document.issuedate", + "identity_document.placebirth", + "identity_document.citizenship.code", + "identity_document.registration_address.name", + ]; + + if(parseInt(_get(signatory_person, "identity_document.doctype"), 10) === 100000000) + { + signatory_person_check.push("identity_document.code"); + signatory_person_check.push("identity_document.issueby"); + } + + if(parseInt(signatory_person.signer_rule_basic, 10) === 100000003) + { + signatory_person_check.push("signer_rule_basic_add"); + } + + if(signatory_person.telephone === "" || signatory_person.telephone === null || isNaN(parseInt(signatory_person.telephone.replace(/[^\d]+/g, ''), 10)) || parseInt(signatory_person.telephone.replace(/[^\d]+/g, ''), 10).toString().length < 11) + { + errors.push(`signatory_person.telephone`); + } + + const email_regex = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/); + if(!email_regex.test(signatory_person.email)) + { + errors.push(`signatory_person.email`); + } + + if(signatory_person_files.length === 0) { errors.push(`signatory_person_files`); } + + if(parseInt(signatory_person.signer_rule_basic, 10) === 100000000 || parseInt(signatory_person.signer_rule_basic, 10) === 100000003) + { + signatory_person_check.push("docdate"); + signatory_person_check.push("docnumber"); + + if(signatory_corporate_files.length === 0) { errors.push(`signatory_corporate_files`); } + } + + for(let i in signatory_person_check) + { + let v = _get(signatory_person, signatory_person_check[i]); + + if(v === "" || v === null) + { + errors.push(`signatory_person.${ signatory_person_check[i] }`); + } + } + + if(parseInt(_get(signatory_person, "identity_document.doctype"), 10) === 100000000 && errors.indexOf("signatory_person.identity_document.seria") < 0 && errors.indexOf("signatory_person.identity_document.docnumber") < 0) + { + const signatory_person_document_check_response = await checkDocumentData({ + seria: signatory_person.identity_document.seria, + number: signatory_person.identity_document.docnumber, + }); + + if(signatory_person_document_check_response[0] !== undefined && signatory_person_document_check_response[0].qc !== 0) + { + errors.push(`signatory_person.identity_document.invalid`); + errors.push(`signatory_person.identity_document.seria`); + errors.push(`signatory_person.identity_document.docnumber`); + } + } + } + + if(head_person_files.length === 0) { errors.push(`head_person_files`); } + + this.setState({ errors, loading: false }, () => + { + window.scroll(0, 0); + if(errors.length === 0) + { + this.ref_submit.current.click(); + } + }); }); } @@ -619,6 +652,11 @@ class Form_3_Signer extends QuestionnaireForm />
+ { errors.indexOf("head_person.identity_document.invalid") > -1 && + ( + + ) } +
@@ -629,7 +667,7 @@ class Form_3_Signer extends QuestionnaireForm name="head_person.identity_document.seria" value={ this._checkStrValue(head_person.identity_document.seria) } placeholder="Введите серию" - onChange={ (event) => { this._removeError("head_person.identity_document.seria"); this._handle_onTextFieldChange(event.target.name, event.target.value) } } + onChange={ (event) => { this._removeError(["head_person.identity_document.seria", "head_person.identity_document.invalid"]); this._handle_onTextFieldChange(event.target.name, event.target.value) } } required={ true } disabled={ checking } /> @@ -643,7 +681,7 @@ class Form_3_Signer extends QuestionnaireForm name="head_person.identity_document.docnumber" value={ this._checkStrValue(head_person.identity_document.docnumber) } placeholder="Введите номер" - onChange={ (event) => { this._removeError("head_person.identity_document.docnumber"); this._handle_onTextFieldChange(event.target.name, event.target.value) } } + onChange={ (event) => { this._removeError(["head_person.identity_document.docnumber", "head_person.identity_document.invalid"]); this._handle_onTextFieldChange(event.target.name, event.target.value) } } required={ true } disabled={ checking }> @@ -1069,6 +1107,11 @@ class Form_3_Signer extends QuestionnaireForm />
+ { errors.indexOf("signatory_person.identity_document.invalid") > -1 && + ( + + ) } +
diff --git a/components/questionnaire/forms/Form_4_Shareholders/index.js b/components/questionnaire/forms/Form_4_Shareholders/index.js index 7cdaa3a..7e15457 100644 --- a/components/questionnaire/forms/Form_4_Shareholders/index.js +++ b/components/questionnaire/forms/Form_4_Shareholders/index.js @@ -19,7 +19,7 @@ import { reduxWrapper } from '../../../../store'; import AddressSuggests from "../../AddressSuggests"; import InputMask from 'react-input-mask'; import { getCitizenshipTitleByCode } from "../../../../utils/citizenship"; -import { saveQuestionnaire } from "../../../../actions"; +import { checkDocumentData, saveQuestionnaire } from "../../../../actions"; import SuggestsInput from "../../SuggestsInput"; import DocumentIssuerSuggestsInput from "../../DocumentIssuerSuggestsInput"; import moment from "moment"; @@ -38,8 +38,6 @@ class ShareholderForm extends React.Component _handle_onCitizenshipChange = (name, value) => { - console.log("_handle_onCitizenshipChange", value); - let citizenship = getCitizenshipTitleByCode(value); this._handle_onFieldChange(name, { title: citizenship, @@ -52,10 +50,7 @@ class ShareholderForm extends React.Component const { index, shareholder, checking, errors } = this.props; let citizenship = { label: getCitizenshipTitleByCode(shareholder.identity_document.citizenship.code), code: shareholder.identity_document.citizenship.code }; - console.log("shareholder", "citizenship", citizenship); - console.log("shareholder", shareholder); - - console.log("shareholder errors", errors); + console.log({ errors }); return ( @@ -166,6 +161,11 @@ class ShareholderForm extends React.Component />
+ { errors.indexOf("identity_document.invalid") > -1 && + ( + + ) } +
@@ -178,7 +178,7 @@ class ShareholderForm extends React.Component name={ `founder_persons[${ index }].identity_document.seria` } value={ this._checkStrValue(shareholder.identity_document.seria) } placeholder="Введите серию" - onChange={ (event) => { this._removeError("identity_document.seria"); this._handle_onTextFieldChange(event.target.name, event.target.value) } } + onChange={ (event) => { this._removeError(["identity_document.seria", "identity_document.invalid"]); this._handle_onTextFieldChange(event.target.name, event.target.value) } } required={ true } disabled={ checking } /> @@ -191,7 +191,7 @@ class ShareholderForm extends React.Component name={ `founder_persons[${ index }].identity_document.docnumber` } value={ this._checkStrValue(shareholder.identity_document.docnumber) } placeholder="Введите номер" - onChange={ (event) => { this._removeError("identity_document.docnumber"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } + onChange={ (event) => { this._removeError(["identity_document.docnumber", "identity_document.invalid"]); this._handle_onTextFieldChange(event.target.name, event.target.value); } } required={ true } disabled={ checking } /> @@ -298,6 +298,10 @@ class ShareholderForm extends React.Component />
+ { index === 0 && errors.indexOf("founder_part_total") > -1 && ( + + ) } +
changeFounderSelectionFromList(`founder_persons[${ index }]`, { ...shareholder, ...contact, ...{ + onChange={ () => changeFounderSelectionFromList(index, `founder_persons[${ index }]`, { ...shareholder, ...contact, ...{ founder_from_list: false, founder_number: shareholders.length, } }) } @@ -535,8 +539,6 @@ class Form_4_Shareholders extends QuestionnaireForm componentDidMount() { - console.log("Form_4_Shareholders", "this.state", this.state); - console.log("Form_4_Shareholders", "global.store.getState()", global.store.getState()); const founder_persons_template = JSON.parse(JSON.stringify(this.state.founder_persons_template)); if(this.state.founder_persons.length === 0) @@ -549,13 +551,9 @@ class Form_4_Shareholders extends QuestionnaireForm _handle_onAddShareholder = () => { - console.log("_handle_onAddShareholder"); - const founder_persons = [ ...this.state.founder_persons ]; const founder_persons_template = JSON.parse(JSON.stringify(this.state.founder_persons_template)); - console.log("_handle_onAddShareholder", { founder_persons_template }); - if(founder_persons.length < 4) { founder_persons.push(founder_persons_template); @@ -581,16 +579,16 @@ class Form_4_Shareholders extends QuestionnaireForm { const founder_persons_template = JSON.parse(JSON.stringify(this.state.founder_persons_template)); const update = { ...founder_persons_template , ...values }; - console.log("_handle_onClearFounderFromListSelection", update); + this._handle_onFieldChange(name, update ); } - _handle_onChangeFounderSelectionFromList = (name, values) => + _handle_onChangeFounderSelectionFromList = (index, name, values) => { - console.log("_handle_onChangeFounderSelectionFromList"); - console.log(name, values); - this._handle_onFieldChange(name, { ...values } ); + const { errors } = this.state; + errors.splice(index, 1); + this.setState({ errors }); } _handle_onIssuerCodeChange = (branch, index, option) => @@ -640,7 +638,6 @@ class Form_4_Shareholders extends QuestionnaireForm _handle_onFormSubmit = (event) => { event.preventDefault(); - console.log("Form_4_Shareholders", "_handle_onFormSubmit"); this._handle_onCheckboxFieldChange("step", 5); setTimeout(() => @@ -650,8 +647,9 @@ class Form_4_Shareholders extends QuestionnaireForm }, 10); } - _handle_onNextPage = () => + _handle_onNextPage = (event) => { + event.preventDefault(); const errors = [ [], [], [], [] ]; @@ -674,54 +672,98 @@ class Form_4_Shareholders extends QuestionnaireForm "identity_document.registration_address.name", ]; - if(parseInt(_get("signatory_person.identity_document.doctype"), 10) === 100000000) + this.setState({ loading: true }, async () => { - } - - for(let f in founder_persons) - { - for(let i in check) + if(parseInt(_get("signatory_person.identity_document.doctype"), 10) === 100000000) { - const v = _get(founder_persons[f], check[i]); - if(check[i] === "telephone") + } + + let total_parts = 0; + + for(let f in founder_persons) + { + for(let i in check) { - if(v === "" || v === null || isNaN(parseInt(v.replace(/[^\d]+/g, ''), 10)) || parseInt(v.replace(/[^\d]+/g, ''), 10).toString().length < 11) + const v = _get(founder_persons[f], check[i]); + if(check[i] === "telephone") { - errors[f].push(`telephone`); + if(v === "" || v === null || isNaN(parseInt(v.replace(/[^\d]+/g, ''), 10)) || parseInt(v.replace(/[^\d]+/g, ''), 10).toString().length < 11) + { + errors[f].push(`telephone`); + } + } + else if(check[i] === "email") + { + const r = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/); + if(!r.test(v)) + { + errors[f].push(`email`); + } + } + else if(check[i] === "founder_part") + { + if(v !== "" || v !== null || !isNaN(parseInt(v, 10))) + { + total_parts = total_parts + parseInt(v, 10) + } + else + { + errors[f].push(`founder_part`); + } + } + else + { + if(v === "" || v === null) + { + errors[f].push(check[i]); + } } } - else if(check[i] === "email") + + if(total_parts > 100) { - const r = new RegExp(/[^@\s]+@[^@\s]+\.[^@\s]+/); - if(!r.test(v)) - { - errors[f].push(`email`); - } + errors[0].push(`founder_part_total`); } - else + + if(parseInt(_get(founder_persons[f], "identity_document.doctype"), 10) === 100000000 && errors.indexOf("identity_document.seria") < 0 && errors.indexOf("identity_document.docnumber") < 0) { - if(v === "" || v === null) + const founder_document_check_response = await checkDocumentData({ + seria: _get(founder_persons[f], "identity_document.seria"), + number: _get(founder_persons[f], "identity_document.docnumber"), + }); + + if(founder_document_check_response[0] !== undefined && founder_document_check_response[0].qc !== 0) { - errors[f].push(check[i]); + errors[f].push(`identity_document.invalid`); + errors[f].push(`identity_document.seria`); + errors[f].push(`identity_document.docnumber`); } } } - } - this.setState({ errors }, () => - { - window.scroll(0, 0); - if(errors.length === 0) + this.setState({ errors, loading: false }, () => { - this.ref_submit.current.click(); - } + window.scroll(0, 0); + let errnum = 0; + for(let i in errors) + { + for(let e in errors[i]) + { + errnum++; + } + } + + if(errnum === 0) + { + this.ref_submit.current.click(); + } + }); }); } _onRemoveError = (index, name) => { const errors = [ ...this.state.errors ]; - console.log("_onRemoveError", { index, name, errors }); if(typeof name === "string") { @@ -764,8 +806,6 @@ class Form_4_Shareholders extends QuestionnaireForm const { checking } = this.props; const { founder_persons, client_contacts, loading, address, status, errors, } = this.state; - //console.log("questionnaire", questionnaire); - return (
{if (e.key === 'Enter') e.preventDefault() }} className={`questionnaire questionnaire_4 ${ checking && "disabled" }`}>

4. Сведения об участниках (акционерах) и бенефициарных владельцах

@@ -809,7 +849,7 @@ class Form_4_Shareholders extends QuestionnaireForm ) : (
) } -
+
-
- { route.indexOf("#status") < 0 && ( - - ) } -
- { this._renderForm() } -
-
+ { loading ? ( +
+ +
+ ) : ( + + { moderation ? ( + +
+ + + + +

+ Анкета подписана и находится на проверке + При необходимости сотрудник Отдела по работе с клиентами свяжется с Вами. +

+
+
+ <> + + +
+
+ ) : ( +
+ { route.indexOf("#status") < 0 && ( + + ) } +
+ { this._renderForm() } +
+
+ ) } +
+ ) }