From 77241319a4409f77c887be9f64acb004ef977e43 Mon Sep 17 00:00:00 2001 From: merelendor Date: Fri, 17 Nov 2023 10:56:30 +0300 Subject: [PATCH] questionnaire form founders part update for percent support --- .../forms/DigitalCertificates.js | 4 +- .../forms/DigitalSignaturesList.js | 51 +++++++---- .../questionnaire/forms/Form_1_Main/index.js | 4 +- .../forms/Form_4_Shareholders/index.js | 86 ++++++++++++++++--- reducers/questionnaireReducer.js | 2 + 5 files changed, 113 insertions(+), 34 deletions(-) diff --git a/components/questionnaire/forms/DigitalCertificates.js b/components/questionnaire/forms/DigitalCertificates.js index 746818b..fc92f02 100644 --- a/components/questionnaire/forms/DigitalCertificates.js +++ b/components/questionnaire/forms/DigitalCertificates.js @@ -86,7 +86,7 @@ export default class DigitalCertificates extends React.Component { if(head_person[fields[i]] !== null && head_person[fields[i]] !== "") { - if(cert_owner.indexOf(head_person[fields[i]].toUpperCase()) < 0) + if(cert_owner.indexOf(head_person[fields[i]].toUpperCase().trim()) < 0) { owner_valid = false; } @@ -267,7 +267,7 @@ export default class DigitalCertificates extends React.Component return ( { certificates_error === "NOT_INSTALLED" && ( - Плагин КриптоПРО не установлен, посмотрите инструкцию как установить плагин КриптоПРО. }/> + Плагин КриптоПРО не установлен, посмотрите инструкцию как установить плагин КриптоПРО. }/> ) } { certificates_error === "CERTIFICATES" && ( Плагин КриптоПРО не активирован, пожалуйста, обновите страницу и подтвердите разрешение для сайта на доступ к списку сертификатов. }/> diff --git a/components/questionnaire/forms/DigitalSignaturesList.js b/components/questionnaire/forms/DigitalSignaturesList.js index ec10de8..89c04cd 100644 --- a/components/questionnaire/forms/DigitalSignaturesList.js +++ b/components/questionnaire/forms/DigitalSignaturesList.js @@ -219,31 +219,48 @@ export default class DigitalSignaturesList extends React.Component else { return ( -
- - - + <> { certificates_error === "NOT_INSTALLED" && ( -

Ошибка - Плагин КриптоПРО не установлен, посмотрите инструкцию как установить плагин КриптоПРО. -

+
+ + + +

Внимание + Плагин КриптоПРО не установлен, посмотрите инструкцию как установить плагин КриптоПРО. +

+
) } { certificates_error === "OTHER" && ( -

Ошибка - Плагин КриптоПРО не активирован, пожалуйста, обновите страницу и подтвердите разрешение для сайта на доступ к списку сертификатов. -

+
+ + + +

Ошибка + Плагин КриптоПРО не активирован, пожалуйста, обновите страницу и подтвердите разрешение для сайта на доступ к списку сертификатов. +

+
) } { certificates_error === "ISSUED" && ( -

Ошибка - Отсутствуют действующие сертификаты. -

+
+ + + +

Ошибка + Отсутствуют действующие сертификаты. +

+
) } { certificates_error === "MISMATCH" && ( -

Ошибка - Подписант не соответствует указанному подписанту в анкете. -

+
+ + + +

Ошибка + Подписант не соответствует указанному подписанту в анкете. +

+
) } -
+ ) } } diff --git a/components/questionnaire/forms/Form_1_Main/index.js b/components/questionnaire/forms/Form_1_Main/index.js index dced84c..9633fd5 100644 --- a/components/questionnaire/forms/Form_1_Main/index.js +++ b/components/questionnaire/forms/Form_1_Main/index.js @@ -303,7 +303,7 @@ class Form_1_Main extends QuestionnaireForm
- -1 ? "error" : "" } id="main.financial_loan" name="main.financial_loan" @@ -318,7 +318,7 @@ class Form_1_Main extends QuestionnaireForm onValueChange={ (value, name) => { this._removeError(name); this._handle_onTextFieldChange(name, value); } } required={ true } disabled={ checking } - /> + />

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

diff --git a/components/questionnaire/forms/Form_4_Shareholders/index.js b/components/questionnaire/forms/Form_4_Shareholders/index.js index c92ab65..c540277 100644 --- a/components/questionnaire/forms/Form_4_Shareholders/index.js +++ b/components/questionnaire/forms/Form_4_Shareholders/index.js @@ -10,6 +10,9 @@ import Select from 'react-select'; import { connect } from "react-redux"; import { withRouter } from 'next/router'; import { get as _get, slice } from 'lodash'; +import InputMask from 'react-input-mask'; +import CurrencyInput from 'react-currency-input-field'; +import moment from "moment"; import QuestionnaireForm from "../QuestionnaireForm"; import CalendarDatePicker from '../../../CalendarDatePicker'; @@ -17,12 +20,10 @@ import citizenships from "../../../../lib/citizenships.json"; import doctypes_personal from "../../../../lib/doctypes_personal.json"; import { reduxWrapper } from '../../../../store'; import AddressSuggests from "../../AddressSuggests"; -import InputMask from 'react-input-mask'; import { getCitizenshipTitleByCode } from "../../../../utils/citizenship"; import { checkDocumentData, saveQuestionnaire } from "../../../../actions"; import SuggestsInput from "../../SuggestsInput"; import DocumentIssuerSuggestsInput from "../../DocumentIssuerSuggestsInput"; -import moment from "moment"; import FormMessage from "../FormMessage"; class ShareholderForm extends React.Component @@ -45,6 +46,44 @@ class ShareholderForm extends React.Component }); } + _handle_onFloatFieldChange = (name, value) => + { + let float = parseFloat(value); + let val = value; + + if(isNaN(float)) + { + val = ""; + } + else if(float > 100) + { + val = 100; + } + else + { + //float = float.toFixed(2); + } + this._handle_onTextFieldChange(name, val); + } + + _renderFloat = (value) => + { + if(this._checkStrValue(value) !== "") + { + const float = parseFloat(value); + if(!isNaN(float)) + { + return float.toFixed(2); + } + else + { + return null; + } + } + + return null; + } + render() { const { index, shareholder, checking, errors } = this.props; @@ -316,20 +355,41 @@ class ShareholderForm extends React.Component { index === 0 && errors.indexOf("founder_part_total") > -1 && ( - + ) }
+ {/*} -1 ? "error" : "" } - mask='999' - formatChars={{ '9': '[0-9]', }} + mask={ [ /[0-9]/, /[0-9]/, /./, /[0-9]/, /[0-9]/ ] } + maskPlaceholder="-" +// 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)); } } + onChange={ (event) => { this._removeError("founder_part"); this._handle_onFloatFieldChange(event.target.name, event.target.value); } } + required={ true } + disabled={ checking } + /> + {*/} + -1 ? "error" : "" } + id={ `founder_persons[${ index }].founder_part` } + name={ `founder_persons[${ index }].founder_part` } +// value={ this._renderFloat(shareholder.founder_part) } + value={ this._checkStrValue(shareholder.founder_part) !== "" && parseFloat(shareholder.founder_part) > 0 ? this._checkStrValue(shareholder.founder_part) : null } +// decimalsLimit={ 2 } + //selectAllOnFocus={ true } + placeholder="Укажите сумму" + decimalSeparator="." + groupSeparator=" " + //suffix=" ₽" + maxLength={ 5 } +// fixedDecimalLength={ 1 } + onValueChange={ (value, name) => { this._removeError(name); this._handle_onFloatFieldChange(name, value); } } required={ true } disabled={ checking } /> @@ -720,9 +780,9 @@ class Form_4_Shareholders extends QuestionnaireForm } else if(check[i] === "founder_part") { - if(v !== "" && v !== null && !isNaN(parseInt(v, 10))) + if(v !== "" && v !== null && !isNaN(parseFloat(v))) { - total_parts = total_parts + parseInt(v, 10) + total_parts = total_parts + parseFloat(v) } else { @@ -738,11 +798,6 @@ class Form_4_Shareholders extends QuestionnaireForm } } - if(total_parts > 100) - { - errors[0].push(`founder_part_total`); - } - if(parseInt(_get(founder_persons[f], "identity_document.doctype"), 10) === 100000000 && errors.indexOf("identity_document.seria") < 0 && errors.indexOf("identity_document.docnumber") < 0) { const founder_document_check_response = await checkDocumentData({ @@ -759,6 +814,11 @@ class Form_4_Shareholders extends QuestionnaireForm } } + if(parseInt(total_parts, 10) !== 100) + { + errors[0].push(`founder_part_total`); + } + this.setState({ errors, loading: false }, () => { window.scroll(0, 0); diff --git a/reducers/questionnaireReducer.js b/reducers/questionnaireReducer.js index 510c236..f35870e 100644 --- a/reducers/questionnaireReducer.js +++ b/reducers/questionnaireReducer.js @@ -19,10 +19,12 @@ const questionnaireReducer = (state = initialState.questionnaire, action) => case actionTypes.QUESTIONNAIRE_UPDATE: { + /* console.log("actionTypes.QUESTIONNAIRE_UPDATE", { ...state, ...action.data.questionnaire, }); + */ return { ...state,