diff --git a/components/questionnaire/forms/Form_1_Main/index.js b/components/questionnaire/forms/Form_1_Main/index.js index 1196fc1..e01ec04 100644 --- a/components/questionnaire/forms/Form_1_Main/index.js +++ b/components/questionnaire/forms/Form_1_Main/index.js @@ -9,7 +9,7 @@ import { SpinnerCircular } from 'spinners-react'; import { connect } from "react-redux"; import { withRouter } from 'next/router'; import InputMask from 'react-input-mask'; -import CurrencyInput from 'react-currency-input'; +import CurrencyInput from 'react-currency-input-field'; import QuestionnaireForm from "../QuestionnaireForm"; import { reduxWrapper } from '../../../../store'; @@ -102,7 +102,7 @@ class Form_1_Main extends QuestionnaireForm if(main.websiteurl !== null && main.websiteurl !== "") { - const r = new RegExp('^(http:\/\/|^https:\/\/)?[a-zA-ZА-я0-9][a-zA-ZА-я0-9-]{1,61}[a-zA-ZА-я0-9](?:\.[a-zA-ZА-я]{2,})+', 'g'); + const r = new RegExp('^(http:\/\/|https:\/\/)?[A-zА-я0-9][A-zА-я0-9-]{1,61}[A-zА-я0-9](?:\.[A-zА-я]{2,})+', 'g'); if(!r.test(main.websiteurl)) { errors.push(`main.websiteurl`); @@ -243,7 +243,8 @@ class Form_1_Main extends QuestionnaireForm placeholder="Например https://example.com" onChange={ (event) => { this._removeError(event.target.name); this._handle_onTextFieldChange(event.target.name, event.target.value); } } disabled={ checking } - pattern="^(http:\/\/|^https:\/\/)?[a-zA-ZА-я0-9][a-zA-ZА-я0-9-]{1,61}[a-zA-ZА-я0-9](?:\.[a-zA-ZА-я]{2,})+" + //pattern="[A-zА-я0-9\-]+" + pattern="^(http:\/\/|https:\/\/)?[A-zА-я0-9][A-zА-я0-9\-]{1,61}[A-zА-я0-9](?:\.[A-zА-я]{2,})+" /> @@ -270,10 +271,14 @@ class Form_1_Main extends QuestionnaireForm id="main.financial_loan" name="main.financial_loan" value={ this._checkStrValue(main.financial_loan) !== "" && parseFloat(main.financial_loan) > 0 ? this._checkStrValue(main.financial_loan) : null } - precision="0" - selectAllOnFocus={ true } + decimalsLimit={ 2 } + //selectAllOnFocus={ true } placeholder="Укажите сумму" - onChangeEvent={ (event) => { this._removeError("main.financial_loan"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } + decimalSeparator="." + groupSeparator=" " + suffix=" ₽" + maxLength={ 12 } + onValueChange={ (value, name) => { this._removeError(name); this._handle_onTextFieldChange(name, value); } } required={ true } disabled={ checking } /> diff --git a/components/questionnaire/forms/Form_2_Contacts/index.js b/components/questionnaire/forms/Form_2_Contacts/index.js index 22d2698..164a64b 100644 --- a/components/questionnaire/forms/Form_2_Contacts/index.js +++ b/components/questionnaire/forms/Form_2_Contacts/index.js @@ -91,7 +91,7 @@ class Form_2_Contacts extends QuestionnaireForm errors.push(`contacts.fact_address`); } - if(main.mail_delivery_address_type === 100000002) + if(parseInt(main.mail_delivery_address_type, 10) === 100000002) { if(contacts.postal_address.name === "") { diff --git a/components/questionnaire/forms/Form_3_Signer/index.js b/components/questionnaire/forms/Form_3_Signer/index.js index 357a82d..43b5a0e 100644 --- a/components/questionnaire/forms/Form_3_Signer/index.js +++ b/components/questionnaire/forms/Form_3_Signer/index.js @@ -30,6 +30,38 @@ import { removeAttachmentFiles, saveQuestionnaire, getSuggests } from "../../../ import DocumentIssuerSuggestsInput from "../../DocumentIssuerSuggestsInput"; import FormMessage from "../FormMessage"; +const is_valid_inn = (i) => +{ + if ( i.match(/\D/) ) return false; + + var inn = i.match(/(\d)/g); + + if ( inn.length == 10 ) + { + return inn[9] == String((( + 2*inn[0] + 4*inn[1] + 10*inn[2] + + 3*inn[3] + 5*inn[4] + 9*inn[5] + + 4*inn[6] + 6*inn[7] + 8*inn[8] + ) % 11) % 10); + } + else if ( inn.length == 12 ) + { + return inn[10] == String((( + 7*inn[0] + 2*inn[1] + 4*inn[2] + + 10*inn[3] + 3*inn[4] + 5*inn[5] + + 9*inn[6] + 4*inn[7] + 6*inn[8] + + 8*inn[9] + ) % 11) % 10) && inn[11] == String((( + 3*inn[0] + 7*inn[1] + 2*inn[2] + + 4*inn[3] + 10*inn[4] + 3*inn[5] + + 5*inn[6] + 9*inn[7] + 4*inn[8] + + 6*inn[9] + 8*inn[10] + ) % 11) % 10); + } + + return false; +} + const suggestsInnDebounce = (query) => { return getSuggests("inn", { query }); @@ -100,8 +132,8 @@ class Form_3_Signer extends QuestionnaireForm middlename: "", no_middle_name: false, jobtitle: "", - signer_rule_basis: "", - signer_rule_basis_add: "", + signer_rule_basic: "", + signer_rule_basic_add: "", docdate: "", docnumber: "", delegation_agreement: false, @@ -283,7 +315,7 @@ class Form_3_Signer extends QuestionnaireForm { this._handle_onBranchChange([ { name: `${ branch }.identity_document.doctype`, value: element.value }, - { name: `${ branch }.identity_document.citizenship_code`, value: element.value === 100000000 ? 643 : null }, + { name: `${ branch }.identity_document.citizenship_code`, value: parseInt(element.value, 10) === 100000000 ? 643 : null }, ]); } @@ -300,7 +332,6 @@ class Form_3_Signer extends QuestionnaireForm "lastname", "firstname", "jobtitle", - "telephone", "email", "identity_document.seria", "identity_document.docnumber", @@ -375,6 +406,17 @@ class Form_3_Signer extends QuestionnaireForm } } + 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) { @@ -390,9 +432,19 @@ class Form_3_Signer extends QuestionnaireForm { let v = _get(main, main_check[i]); - if(v === "" || v === null) + if(main_check[i] === "individual_executive_inn") { - errors.push(`main.${ main_check[i] }`); + 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] }`); + } } } @@ -406,8 +458,7 @@ class Form_3_Signer extends QuestionnaireForm "lastname", "firstname", "jobtitle", - "signer_rule_basis", - "telephone", + "signer_rule_basic", "email", "identity_document.seria", "identity_document.docnumber", @@ -415,8 +466,6 @@ class Form_3_Signer extends QuestionnaireForm "identity_document.placebirth", "identity_document.citizenship.code", "identity_document.registration_address.name", - "docnumber", - "docdate", ]; if(parseInt(_get(signatory_person, "identity_document.doctype"), 10) === 100000000) @@ -425,15 +474,30 @@ class Form_3_Signer extends QuestionnaireForm signatory_person_check.push("identity_document.issueby"); } - if(signatory_person.signer_rule_basis === 100000003) + if(parseInt(signatory_person.signer_rule_basic, 10) === 100000003) { - signatory_person_check.push("signer_rule_basis_add"); + signatory_person_check.push("signer_rule_basic_add"); } - if(signatory_person.signer_rule_basis === 100000001 || signatory_person.signer_rule_basis === 100000003) + 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) @@ -445,9 +509,6 @@ class Form_3_Signer extends QuestionnaireForm errors.push(`signatory_person.${ signatory_person_check[i] }`); } } - - if(signatory_person_files.length === 0) { errors.push(`signatory_person_files`); } - if(signatory_corporate_files.length === 0) { errors.push(`signatory_corporate_files`); } } if(head_person_files.length === 0) { errors.push(`head_person_files`); } @@ -712,13 +773,14 @@ class Form_3_Signer extends QuestionnaireForm
- -1 ? "error" : "" } id={ "head_person.email" } name={ "head_person.email" } value={ this._checkStrValue(head_person.email) } placeholder="Введите E-mail" onChange={ (event) => { this._removeError(event.target.name); this._handle_onTextFieldChange(event.target.name, event.target.value); } } + pattern="[^@\s]+@[^@\s]+\.[^@\s]+" required={ true } disabled={ checking } /> @@ -817,6 +879,11 @@ class Form_3_Signer extends QuestionnaireForm

Информация об управляющей организации или управляющем

+ { errors.indexOf("main.individual_executive_inn") > -1 && + ( + + ) } +
@@ -1157,13 +1224,14 @@ class Form_3_Signer extends QuestionnaireForm
- -1 ? "error" : "" } id="signatory_person.email" name="signatory_person.email" value={ this._checkStrValue(signatory_person.email) } placeholder="E-mail" onChange={ (event) => { this._removeError("signatory_person.email"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } + pattern="[^@\s]+@[^@\s]+\.[^@\s]+" required={ true } disabled={ checking } /> @@ -1190,38 +1258,38 @@ class Form_3_Signer extends QuestionnaireForm
-1 ? "error" : "" } - id="signatory_person.signer_rule_basis_add" - name="signatory_person.signer_rule_basis_add" - value={ this._checkStrValue(signatory_person.signer_rule_basis_add) } + className={ errors.indexOf("signatory_person.signer_rule_basic_add") > -1 ? "error" : "" } + id="signatory_person.signer_rule_basic_add" + name="signatory_person.signer_rule_basic_add" + value={ this._checkStrValue(signatory_person.signer_rule_basic_add) } placeholder="Наименование документа" - onChange={ (event) => { this._removeError("signatory_person.signer_rule_basis_add"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } + onChange={ (event) => { this._removeError("signatory_person.signer_rule_basic_add"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } required={ true } disabled={ checking } />
) } - { (signatory_person.signer_rule_basis === 100000000 || signatory_person.signer_rule_basis === 100000003) && ( + { (parseInt(signatory_person.signer_rule_basic, 10) === 100000000 || parseInt(signatory_person.signer_rule_basic, 10) === 100000003) && ( <>
diff --git a/components/questionnaire/forms/Form_4_Shareholders/index.js b/components/questionnaire/forms/Form_4_Shareholders/index.js index b249121..9525130 100644 --- a/components/questionnaire/forms/Form_4_Shareholders/index.js +++ b/components/questionnaire/forms/Form_4_Shareholders/index.js @@ -126,7 +126,7 @@ class ShareholderForm extends React.Component name={ `founder_persons[${ index }].telephone` } value={ this._checkStrValue(shareholder.telephone) } placeholder="Введите номер телефона" - onChange={ (event) => { this._removeError("telephone"); this._handle_onTextFieldChange(event.target.name, event.target.value) } } + onChange={ (event) => { if(event.target.value !== "" && !isNaN(parseInt(event.target.value.replace(/[^\d]+/g, ''), 10)) && parseInt(event.target.value.replace(/[^\d]+/g, ''), 10) > 7) { this._removeError("telephone"); } this._handle_onTextFieldChange(event.target.name, event.target.value) } } required={ true } disabled={ checking } /> @@ -134,13 +134,14 @@ class ShareholderForm extends React.Component
- -1 ? "error" : "" } id={ `founder_persons[${ index }].email` } name={ `founder_persons[${ index }].email` } value={ this._checkStrValue(shareholder.email) } placeholder="Введите E-mail" onChange={ (event) => { this._removeError("email"); this._handle_onTextFieldChange(event.target.name, event.target.value) } } + pattern="[^@\s]+@[^@\s]+\.[^@\s]+" required={ true } disabled={ checking } /> @@ -297,6 +298,50 @@ class ShareholderForm extends React.Component />
+
+ + -1 ? "error" : "" } + mask='999' + formatChars={{ '9': '[0-9]', }} + id={ `founder_persons[${ index }].founder_part` } + name={ `founder_persons[${ index }].founder_part` } + value={ this._checkStrValue(shareholder.founder_part) } + placeholder="Укажите размер доли" + onChange={ (event) => { this._removeError("founder_part"); this._handle_onTextFieldChange(event.target.name, parseInt(event.target.value, 10) > 100 ? 100 : parseInt(event.target.value, 10)); } } + required={ true } + disabled={ checking } + /> +
+ +
+ +
+
+ this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) } + disabled={ checking } + /> + +
+
+ this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) } + disabled={ checking } + /> + +
+
+
+ ) } @@ -341,137 +386,85 @@ class Shareholder extends React.Component
- { index > 0 && ( -
- -
+
+ +
- { !checking && ( -
- clearFounderFromListSelection(`founder_persons[${ index }]`, { founder_from_list: !shareholder.founder_from_list ? true : false, lastname: "", firstname: "", middlename: "", no_middle_name: false, }) } + { !checking && ( +
+ clearFounderFromListSelection(`founder_persons[${ index }]`, { founder_from_list: !shareholder.founder_from_list ? true : false, lastname: "", firstname: "", middlename: "", no_middle_name: false, }) } + /> + +
+ ) } + + { !checking && ( + + ) } + +
+
+ + { shareholder.founder_from_list ? ( +
+
+ + { contacts !== undefined && contacts !== null && contacts.map((contact, s_index) => + { + const hash = `${ contact.lastname }_${ contact.firstname }_${ contact.middlename }`; + const disabled = hash !== shareholder.hash ? this._checkContactListDisabled(hash) : false; + + if(checking) + { + if(shareholder.hash !== hash) + { + return null; + } + } + + return ( +
+ changeFounderSelectionFromList(`founder_persons[${ index }]`, { ...shareholder, ...contact, ...{ + founder_from_list: false, + founder_number: shareholders.length, + } }) } + disabled={ disabled } /> - -
- ) } - - { !checking && ( - - ) } - + +
+ ); + }) }
- ) } - - { index > 0 ? ( - - { shareholder.founder_from_list ? ( -
-
- - { contacts !== undefined && contacts !== null && contacts.map((contact, s_index) => - { - const hash = `${ contact.lastname }_${ contact.firstname }_${ contact.middlename }`; - const disabled = hash !== shareholder.hash ? this._checkContactListDisabled(hash) : false; - - if(checking) - { - if(shareholder.hash !== hash) - { - return null; - } - } - - return ( -
- changeFounderSelectionFromList(`founder_persons[${ index }]`, { ...shareholder, ...contact, ...{ - founder_from_list: false, - founder_number: shareholders.length, - } }) } - disabled={ disabled } - /> - -
- ); - }) } -
-
- ) : ( - - ) } -
) : ( ) } - -
- - -1 ? "error" : "" } - mask='999' - formatChars={{ '9': '[0-9]', }} - id={ `founder_persons[${ index }].founder_part` } - name={ `founder_persons[${ index }].founder_part` } - value={ this._checkStrValue(shareholder.founder_part) } - placeholder="Укажите размер доли" - onChange={ (event) => { this._removeError("founder_part"); this._handle_onTextFieldChange(event.target.name, parseInt(event.target.value, 10) > 100 ? 100 : parseInt(event.target.value, 10)); } } - required={ true } - disabled={ checking } - /> -
- -
- -
-
- this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) } - disabled={ checking } - /> - -
-
- this._handle_onCheckboxFieldChange(event.target.name, parseInt(event.target.value, 10)) } - disabled={ checking } - /> - -
-
-
@@ -640,7 +633,7 @@ class Form_4_Shareholders extends QuestionnaireForm { this._handle_onBranchChange([ { name: `${ branch }.identity_document.doctype`, value: element.value }, - { name: `${ branch }.identity_document.citizenship_code`, value: element.value === 100000000 ? 643 : null }, + { name: `${ branch }.identity_document.citizenship_code`, value: parseInt(element.value, 10) === 100000000 ? 643 : null }, ]); } @@ -690,10 +683,27 @@ class Form_4_Shareholders extends QuestionnaireForm for(let i in check) { const v = _get(founder_persons[f], check[i]); - - if(v === "" || v === null) + if(check[i] === "telephone") { - errors[f].push(check[i]); + 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(v === "" || v === null) + { + errors[f].push(check[i]); + } } } } @@ -795,12 +805,12 @@ class Form_4_Shareholders extends QuestionnaireForm { !checking && (
{ founder_persons.length < 4 ? ( - + ) : (
) }
-