diff --git a/actions/questionnaireActions.js b/actions/questionnaireActions.js index 64733c3..110ff52 100644 --- a/actions/questionnaireActions.js +++ b/actions/questionnaireActions.js @@ -248,13 +248,14 @@ export const uploadAttachmentFile = (file) => }); } -export const uploadSignedFile = (file, id) => +export const uploadSignedFile = (file, id, digital = false) => { return new Promise((resolve, reject) => { let data = new FormData(); data.append('file', file); data.append('id', id); + data.append('digital', digital); axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/send`, data, { @@ -365,4 +366,9 @@ export const downloadQuestionnaire = ({ filename, download = true }) => }); }); -} \ No newline at end of file +} + +export const questionnaireSetSign = ({ dispatch, sign }) => +{ + dispatch({ type: actionTypes.QUESTIONNAIRE_SET_SIGN, data: { sign } }); +} \ No newline at end of file diff --git a/components/questionnaire/AddressSuggests.js b/components/questionnaire/AddressSuggests.js index ad8b391..28f6635 100644 --- a/components/questionnaire/AddressSuggests.js +++ b/components/questionnaire/AddressSuggests.js @@ -118,14 +118,14 @@ export default class AddressSuggests extends React.Component render() { const { focused, options } = this.state; - const { value, disabled, required, placeholder } = this.props; + const { value, disabled, required, placeholder, className } = this.props; return (
{ + const { company, onSignDigital } = this.props; + downloadQuestionnaire({ download: false }) .then(({ file, filename }) => { @@ -91,13 +93,23 @@ export default class DigitalSignaturesList extends React.Component const now = moment().format("DDMMYYYY_HHmmss"); generateSignature(file_to_sign, this.state.certificate_selected.certificate) - .then(signature => { + .then(signature => + { console.log("signature"); console.log(signature); - fileDownload(signature, `${ now }_${ filename }.sig`); - fileDownload(file, `${ now }_${ filename }`); - alert("Подписание ЭЦП прошло успешно."); + uploadSignedFile(signature, company.questionnaire_id) + .then(() => + { + onSignDigital(); + }) + .catch(() => + { + }); + + //fileDownload(signature, `${ now }_${ filename }.sig`); + //fileDownload(file, `${ now }_${ filename }`); + //alert("Подписание ЭЦП прошло успешно."); }); }) .catch((e) => @@ -114,8 +126,11 @@ export default class DigitalSignaturesList extends React.Component 'The card cannot be accessed because the wrong PIN was presented. (0x8010006B)': 'Указанный пароль неверный' } - let errorText = errorsText[e.message] || 'Ошибка подписания файла'; - alert(errorText); + if(e !== undefined) + { + let errorText = errorsText[e.message] || 'Ошибка подписания файла'; + alert(errorText); + } }); } diff --git a/components/questionnaire/forms/Form_1_Main/index.js b/components/questionnaire/forms/Form_1_Main/index.js index b4b3abb..c4077c4 100644 --- a/components/questionnaire/forms/Form_1_Main/index.js +++ b/components/questionnaire/forms/Form_1_Main/index.js @@ -57,7 +57,11 @@ class Form_1_Main extends QuestionnaireForm step: 1, status: "empty", loading: false, + errors: [], }; + + this.ref_form = React.createRef(); + this.ref_submit = React.createRef(); } static getDerivedStateFromProps(nextProps, prevState) @@ -73,8 +77,13 @@ class Form_1_Main extends QuestionnaireForm { } - _checkDisabled = () => + _handle_onNextPage = (event) => { + console.log("Form_1_Main", "_handle_onNextPage"); + event.preventDefault(); + + const errors = []; + const { main } = this.state; const { company } = this.props; const check = ["title", "inn", "kpp", "email", "telephone", "financial_loan"]; @@ -87,11 +96,14 @@ class Form_1_Main extends QuestionnaireForm { if(main[check[i]] === "") { - return true; + errors.push(`main.${ check[i] }`); } } - return false; + this.setState({ errors }, () => + { + this.ref_submit.current.click(); + }); } _handle_onNonProfitChange = () => @@ -135,25 +147,38 @@ class Form_1_Main extends QuestionnaireForm render() { const { company, checking } = this.props; - const { loading, main, status } = this.state; + const { loading, main, status, errors, } = this.state; const firstLetter = /(?!.*[DFIOQU])[A-VXY]/i; const letter = /(?!.*[DFIOQU])[A-Z]/i; const digit = /[0-9]/; const fin_mask = [firstLetter, digit, letter, " ", digit, letter, digit]; + console.log({ errors }); + return ( -
+ {if (e.key === 'Enter') e.preventDefault() }} className={`questionnaire questionnaire_1 ${ checking && "disabled" }`}>

1. Информация о лизингополучателе

- + { errors.length > 0 && + ( +
+ + + +

Ошибка + Пожалуйста, проверьте корректность заполнения данных в форме. +

+
+ ) }
-1 ? "error" : "" } id="main.title" name="main.title" value={ this._checkStrValue(main.title) } placeholder="Введите наименование" - onChange={ (event) => this._handle_onTextFieldChange(event.target.name, event.target.value) } + onChange={ (event) => { this._removeError("main.title"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } required={ true } disabled={ true } /> @@ -163,11 +188,12 @@ class Form_1_Main extends QuestionnaireForm
-1 ? "error" : "" } id="main.inn" name="main.inn" value={ this._checkStrValue(main.inn) } placeholder="Введите ИНН" - onChange={ (event) => this._handle_onTextFieldChange(event.target.name, event.target.value) } + onChange={ (event) => {this._removeError("main.inn"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } required={ true } disabled={ true } maxLength={ 12 } @@ -177,11 +203,12 @@ class Form_1_Main extends QuestionnaireForm
-1 ? "error" : "" } id="main.kpp" name="main.kpp" value={ this._checkStrValue(main.kpp) } placeholder="Введите КПП" - onChange={ (event) => this._handle_onTextFieldChange(event.target.name, event.target.value) } + onChange={ (event) => {this._removeError("main.kpp"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } required={ true } disabled={ true } /> @@ -193,12 +220,13 @@ class Form_1_Main extends QuestionnaireForm
-1 ? "error" : "" } mask='+7 (999) 999 99 99' id="main.telephone" name="main.telephone" value={ this._checkStrValue(main.telephone) } placeholder="Введите номер" - onChange={ (event) => 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("main.telephone"); } this._handle_onTextFieldChange(event.target.name, event.target.value); } } required={ true } disabled={ checking } > @@ -211,7 +239,7 @@ class Form_1_Main extends QuestionnaireForm name="main.websiteurl" value={ this._checkStrValue(main.websiteurl) } placeholder="Введите адрес сайта, если есть" - onChange={ (event) => this._handle_onTextFieldChange(event.target.name, event.target.value) } + onChange={ (event) => { this._handle_onTextFieldChange(event.target.name, event.target.value); } } disabled={ checking } />
@@ -220,11 +248,13 @@ class Form_1_Main extends QuestionnaireForm
-1 ? "error" : "" } id="main.email" name="main.email" value={ this._checkStrValue(main.email) } placeholder="Укажите адрес электронной почты" - onChange={ (event) => this._handle_onTextFieldChange(event.target.name, event.target.value) } + onChange={ (event) => { this._removeError("main.email"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } + required={ true } disabled={ checking } />

может использоваться для отправки лизингодателем юридически значимых сообщений в соответсвии с условиями договора лизинга, а так же для операций в электронном ПТС/ПСМ

@@ -233,14 +263,16 @@ class Form_1_Main extends QuestionnaireForm
this._handle_onTextFieldChange(event.target.name, event.target.value) } - disabled={ checking } + className={ errors.indexOf("main.financial_loan") > -1 ? "error" : "" } + 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 } + placeholder="Укажите сумму" + onChangeEvent={ (event) => { this._removeError("main.financial_loan"); this._handle_onTextFieldChange(event.target.name, event.target.value); } } + required={ true } + disabled={ checking } />

сумма текущих ежемесячных платежей по действующим кредитам/договорам лизинга

@@ -277,17 +309,18 @@ class Form_1_Main extends QuestionnaireForm { !checking && (
- +
) } diff --git a/components/questionnaire/forms/Form_2_Contacts/index.js b/components/questionnaire/forms/Form_2_Contacts/index.js index ac310a2..dccd71c 100644 --- a/components/questionnaire/forms/Form_2_Contacts/index.js +++ b/components/questionnaire/forms/Form_2_Contacts/index.js @@ -38,7 +38,11 @@ class Form_2_Contacts extends QuestionnaireForm fias_id: null, }, }, + errors: [], }; + + this.ref_form = React.createRef(); + this.ref_submit = React.createRef(); } static getDerivedStateFromProps(nextProps, prevState) @@ -73,49 +77,65 @@ class Form_2_Contacts extends QuestionnaireForm }, 10); } - _checkDisabled = () => + _handle_onNextPage = () => { const { contacts } = this.state; + + const errors = []; const check = ["fact_address", "legal_address", "postal_address"]; - if(contacts.address_type === "fact") + if(contacts.fact_address.name === "") { - if(contacts.fact_address.name === "") - { - return true; - } + errors.push(`contacts.fact_address`); } if(contacts.address_type === "postal") { if(contacts.postal_address.name === "") { - return true; + errors.push(`contacts.postal_address`); } } - return false; + this.setState({ errors }, () => + { + this.ref_submit.current.click(); + }); } render() { const { company, checking } = this.props; - const { contacts, loading, status, step } = this.state; + const { contacts, loading, status, step, errors } = this.state; const { address_type, legal_address, fact_address, postal_address, } = contacts; + console.log("errors", errors); + return ( -
+ {if (e.key === 'Enter') e.preventDefault() }} className={`questionnaire questionnaire_2 ${ checking && "disabled" }`}>

2. Адреса лизингополучателя

+ { errors.length > 0 && + ( +
+ + + +

Ошибка + Пожалуйста, проверьте корректность заполнения данных в форме. +

+
+ ) }
- + -1 ? "error" : "" } value={ this._checkStrValue(fact_address.name) } fias={ this._checkStrValue(fact_address.fias_id) } - onChange={ (data) => this._handle_onTextFieldChange("contacts.fact_address", data) } - required={ address_type === "fact" ? true : false } - disabled={ checking ? true : address_type === "fact" ? false : true } + onChange={ (data) => { this._removeError("contacts.fact_address"); this._handle_onTextFieldChange("contacts.fact_address", data); } } + required={ true } + disabled={ false } />

для юр.диц - заполняется, если отличается от указанного в ЕГРЮЛ; для ИП - заполняется всегда

@@ -132,7 +152,7 @@ class Form_2_Contacts extends QuestionnaireForm id="contacts.address_type_legal" name="contacts.address_type" checked={ address_type === "legal" ? true : false } - onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, event.target.value) } + onChange={ (event) => { this._removeError("contacts.postal_address"); this._handle_onCheckboxFieldChange(event.target.name, event.target.value); } } disabled={ checking } /> @@ -145,7 +165,7 @@ class Form_2_Contacts extends QuestionnaireForm id="contacts.address_type_fact" name="contacts.address_type" checked={ address_type === "fact" ? true : false } - onChange={ (event) => this._handle_onCheckboxFieldChange(event.target.name, event.target.value) } + onChange={ (event) => { this._removeError("contacts.postal_address"); this._handle_onCheckboxFieldChange(event.target.name, event.target.value); } } disabled={ checking } /> @@ -163,9 +183,10 @@ class Form_2_Contacts extends QuestionnaireForm
) } @@ -398,13 +401,14 @@ class Shareholder 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._handle_onTextFieldChange(event.target.name, event.target.value > 100 ? 100 : event.target.value) } + onChange={ (event) => { _removeError("founder_part"); this._handle_onTextFieldChange(event.target.name, event.target.value > 100 ? 100 : event.target.value); } } required={ true } disabled={ checking } /> @@ -486,7 +490,13 @@ class Form_4_Shareholders extends QuestionnaireForm }, loading: false, status: "empty", + errors: [ + [], [], [], [] + ], }; + + this.ref_form = React.createRef(); + this.ref_submit = React.createRef(); } static getDerivedStateFromProps(nextProps, prevState) @@ -570,14 +580,16 @@ class Form_4_Shareholders extends QuestionnaireForm }, 10); } - _checkDisabled = () => + _handle_onNextPage = () => { - const { founder_persons } = this.state; - const check_all = [ - "founder_part", + const errors = [ + [], [], [], [] ]; + const { founder_persons } = this.state; + const check = [ + "founder_part", "lastname", "firstname", "telephone", @@ -594,36 +606,40 @@ class Form_4_Shareholders extends QuestionnaireForm for(let f in founder_persons) { - for(let i in check_all) + for(let i in check) { - if(_get(founder_persons[f], check_all[i]) === "") + if(_get(founder_persons[f], check[i]) === "") { - console.log("1. EMPTY", f, check_all[i]); - return true; + errors[f].push(check[i]); } } + } - if(!founder_persons[f].founder_from_list) - { - for(let i in check) - { - if(_get(founder_persons[f], check[i]) === "") - { - console.log("2. EMPTY", f, check[i]); - return true; - } - } - } - else - { - if(founder_persons[f].signatory_id === null) - { - console.log("3. EMPTY", f, "signatory_id"); - console.log("founder_persons[f]"); - console.log(founder_persons[f]); + this.setState({ errors }, () => + { + this.ref_submit.current.click(); + }); + } - return true; - } + _onRemoveError = (index, name) => + { + const errors = [ ...this.state.errors ]; + if(errors.indexOf(name) > -1) + { + errors[index].splice(errors[index].indexOf(name), 1); + } + this.setState({ errors }); + } + + _checkErrorsList = () => + { + const { errors } = this.state; + + for(let i in errors) + { + if(errors[i].length > 0) + { + return true; } } @@ -633,10 +649,10 @@ class Form_4_Shareholders extends QuestionnaireForm render() { const { signatories, checking } = this.props; - const { founder_persons, loading, address, status, } = this.state; + const { founder_persons, loading, address, status, errors, } = this.state; return ( - + {if (e.key === 'Enter') e.preventDefault() }} className={`questionnaire questionnaire_4 ${ checking && "disabled" }`}>

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

– физических лицах, владеющих долей в уставном капитале более 25% *бенефициарный владелец (в соответствии с Федеральным законом от 07.08.2001 No115-ФЗ «О противодействии легализации (отмыванию) доходов, полученных преступным путем, и финансированию терроризма») — @@ -644,17 +660,29 @@ class Form_4_Shareholders extends QuestionnaireForm имеет возможность контролировать действия вышеуказанного лизингополучателя. Бенефициарным владельцем лизингополучателя-физического лица считается это лицо, за исключением случаев, если имеются основания полагать, что бенефициарным владельцем является иное физическое лицо. В случае, если бенефициарным владельцем являются несколько человек, сведения предоставляются в отношении каждого.

- + { this._checkErrorsList() && + ( +
+ + + +

Ошибка + Пожалуйста, проверьте корректность заполнения данных в форме. +

+
+ ) } { founder_persons.map((shareholder, index) => ( this._onRemoveError(index, name) } removeShareholder={ this._handle_onRemoveShareholder } clearSignatorySelection={ this._handle_onClearSignatorySelection } changeSignatorySelection={ this._handle_onChangeSignatorySelection } @@ -671,11 +699,12 @@ class Form_4_Shareholders extends QuestionnaireForm
) }
- +