From 3e2309feb4efe89c17b068fecde86ae4d66ca989 Mon Sep 17 00:00:00 2001 From: merelendor Date: Thu, 20 Apr 2023 10:37:45 +0300 Subject: [PATCH] pre-release hotfixes --- .../forms/DigitalCertificates.js | 21 +- components/questionnaire/forms/FormMessage.js | 23 +- .../forms/Form_3_Signer/index.js | 22 +- .../forms/Form_8_Signing/index.js | 251 ++++++++++-------- .../forms/Form_9_Status/index.js | 112 ++++---- .../questionnaire/forms/QuestionnaireForm.js | 1 + pages/questionnaire/index.js | 3 + reducers/initialState.js | 3 +- 8 files changed, 240 insertions(+), 196 deletions(-) diff --git a/components/questionnaire/forms/DigitalCertificates.js b/components/questionnaire/forms/DigitalCertificates.js index 3bb089f..59f78e0 100644 --- a/components/questionnaire/forms/DigitalCertificates.js +++ b/components/questionnaire/forms/DigitalCertificates.js @@ -48,9 +48,16 @@ export default class DigitalCertificates extends React.Component this.cryptopro.certificateInfo(certificate.id) .then((cert) => { - if(cert.IsValid) + if(cert.Subject['INNLE'] !== undefined && cert.Subject['INNLE'] !== null && cert.Subject['INNLE'] !== "") { - callback(null, [ { id: certificate.id, fields: cert.Subject, valid_to_date: moment(cert.ValidToDate).format("DD.MM.YYYY") } ]); + if(cert.IsValid) + { + callback(null, [ { id: certificate.id, fields: cert.Subject, valid_to_date: moment(cert.ValidToDate).format("DD.MM.YYYY") } ]); + } + else + { + callback(null, []); + } } else { @@ -87,7 +94,7 @@ export default class DigitalCertificates extends React.Component this.setState({ signing: true }, () => { const { company, main, onSignDigital } = this.props; - const filename = `${ main.inn }_questionnaire_${ moment().format("DDMMYYYY_HHmmss") }.pdf`; + const filename = `${ main.inn }_questionnaire_${ moment().format("DDMMYYYY_HHmmss") }.sig`; downloadQuestionnaire({ filename, download: false, base64: true }) .then(({ file }) => @@ -98,7 +105,9 @@ export default class DigitalCertificates extends React.Component this.cryptopro.signData(file_to_sign, this.state.certificate_selected.id) .then(signature => { - uploadSignedFile(signature, company.questionnaire_id, true) + console.log({ signature }); + let signature_file = new File([ signature ], filename); + uploadSignedFile(signature_file, company.questionnaire_id, true) .then(() => { onSignDigital(); @@ -163,11 +172,11 @@ export default class DigitalCertificates extends React.Component { certificate.fields['SN'] ? ({ certificate.fields['SN'] } { certificate.fields['G'] }) : null }

- ИНН { certificate.fields['INN'] } + ИНН { certificate.fields['INNLE'] }

{ certificate.fields['OGRNIP'] && (ОГРНИП { certificate.fields['OGRNIP'] }) } - { certificate.fields['OGRN'] && (ОГРН { certificate.fields['ОГРН'] }) } + { certificate.fields['OGRN'] && (ОГРН { certificate.fields['OGRN'] }) }

Подпись действительна до { certificate.valid_to_date } diff --git a/components/questionnaire/forms/FormMessage.js b/components/questionnaire/forms/FormMessage.js index 924927e..7e5ebef 100644 --- a/components/questionnaire/forms/FormMessage.js +++ b/components/questionnaire/forms/FormMessage.js @@ -11,13 +11,26 @@ export default class FormMessage extends React.Component render() { - const { type, title, message } = this.props; + const { type, title, message, style } = this.props; return ( -

- - - +
+ { type === "success" && ( + + + + + ) } + { type === "moderate" && ( + + + + ) } + { type === "error" && ( + + + + ) }

{ title } { message }

diff --git a/components/questionnaire/forms/Form_3_Signer/index.js b/components/questionnaire/forms/Form_3_Signer/index.js index 6c959dd..af4f929 100644 --- a/components/questionnaire/forms/Form_3_Signer/index.js +++ b/components/questionnaire/forms/Form_3_Signer/index.js @@ -608,21 +608,21 @@ class Form_3_Signer extends QuestionnaireForm errors.push(`signatory_person.identity_document.docnumber`); } } + + if(head_person.lastname !== null && head_person.lastname !== "" && head_person.firstname !== null && head_person.firstname !== "") + { + if(signatory_person.lastname !== null && signatory_person.lastname !== "" && signatory_person.firstname !== null && signatory_person.firstname !== "") + { + if(head_person.lastname === signatory_person.lastname && head_person.firstname === signatory_person.firstname) + { + errors.push(`signatory_person.identical`); + } + } + } } if(head_person_files.length === 0) { errors.push(`head_person_files`); } - if(head_person.lastname !== null && head_person.lastname !== "" && head_person.firstname !== null && head_person.firstname !== "") - { - if(signatory_person.lastname !== null && signatory_person.lastname !== "" && signatory_person.firstname !== null && signatory_person.firstname !== "") - { - if(head_person.lastname === signatory_person.lastname && head_person.firstname === signatory_person.firstname) - { - errors.push(`signatory_person.identical`); - } - } - } - this.setState({ errors, loading: false }, () => { window.scroll(0, 0); diff --git a/components/questionnaire/forms/Form_8_Signing/index.js b/components/questionnaire/forms/Form_8_Signing/index.js index b7d0790..849dd77 100644 --- a/components/questionnaire/forms/Form_8_Signing/index.js +++ b/components/questionnaire/forms/Form_8_Signing/index.js @@ -14,8 +14,7 @@ import NoSSR from "@mpth/react-no-ssr"; import QuestionnaireForm from "../QuestionnaireForm"; import { MatchMedia } from '../../../../utils/mediaqueries'; import { reduxWrapper } from '../../../../store'; -import DigitalSignaturesList from "../DigitalSignaturesList"; -import { downloadQuestionnaire } from "../../../../actions"; +import { downloadQuestionnaire, saveQuestionnaire } from "../../../../actions"; import DigitalCertificates from "../DigitalCertificates"; import FormMessage from "../FormMessage"; @@ -25,6 +24,7 @@ class Form_8_Signing extends QuestionnaireForm { super(props); this.state = { + loading: true, main: {}, signatory_person: {}, sign_digital: true, @@ -35,6 +35,7 @@ class Form_8_Signing extends QuestionnaireForm downloading: false, error: false, digital_disabled: false, + sign: {}, }; } @@ -43,21 +44,37 @@ class Form_8_Signing extends QuestionnaireForm return { main: nextProps.questionnaire.main, signatory_person: nextProps.questionnaire.signatory_person, + sign: nextProps.questionnaire.sign, company: nextProps.company, }; } componentDidMount() { - const { main, signatory_person } = this.state; - const update = { filename: `${ main.inn }_questionnaire_${ moment().format("DDMMYYYY_HHmmss") }.pdf` }; - if(signatory_person.not_head_person) - { - update.sign_digital = false; - update.digital_disabled = true; - } + console.log("Form_8_Signing", "CDM"); - this.setState({ ...this.state, ...update }); + //setTimeout(() => + //{ + console.log("Form_8_Signing", "CDM", { state: this.state }); + + const { main, signatory_person } = this.state; + const update = { filename: `${ main.inn }_questionnaire_${ moment().format("DDMMYYYY_HHmmss") }.pdf` }; + let digital = true; + + if(signatory_person.not_head_person) + { + update.digital_disabled = true; + digital = false; + } + + this.setState({ ...this.state, ...update, ...{ loading: false } }, () => + { + this._handle_onBranchChange([ + { name: `sign.digital`, value: digital }, + ]); + }); + + //}, 50); } _handle_onFormSubmit = (event) => @@ -86,129 +103,147 @@ class Form_8_Signing extends QuestionnaireForm { this.setState({ downloading: true }, () => { - downloadQuestionnaire({ filename, download: true }) + saveQuestionnaire() .then(() => { - this._handle_onCheckboxFieldChange("step", 9); - setTimeout(() => + downloadQuestionnaire({ filename, download: true }) + .then(() => { - this.props.onNextStep("status"); - this.props.onSuccess(); - }, 10); + this._handle_onCheckboxFieldChange("step", 9); + setTimeout(() => + { + this.props.onNextStep("status"); + }, 10); + }) + .catch(() => + { + this.setState({ downloading: false, error: true, }) + }); }) .catch(() => { this.setState({ downloading: false, error: true, }) - }) - }); + }); + }); } } _handle_onChangeSignMethod = () => { - const { sign_digital } = this.state; - this.setState({ sign_digital: sign_digital ? false : true }, () => - { - window.scrollTo(0, 0); - }); + const { sign } = this.state; + this._handle_onBranchChange([ + { name: `sign.digital`, value: sign.digital ? false : true }, + ]); + window.scrollTo(0, 0); } render() { - const { filename, sign_digital, mobile, company, main, downloading, error, digital_disabled } = this.state; + const { loading, filename, sign_digital, sign, mobile, company, main, downloading, error, digital_disabled } = this.state; - return ( - -
-

8. Выбор метода подписания

+ console.log({ sign }); -
-
-
- - -
-
-
+ if(loading) + { + return ( +
+ +
+ ); + } + else + { + return ( + + +

8. Выбор метода подписания

- { sign_digital && ( - <> - { digital_disabled ? ( -
- - - -

Внимание - Подписант отличается от Единоличного исполнительного органа. Подписание посредством ЭЦП недоступно. -

+
+
+
+ +
- ) : ( - <> - { mobile ? ( -
- - - -

Внимание - Для подписания анкеты посредством ЭЦП пожалуйста воспользуйтесь стационарным компьютером или ноутбуком с установленной программой КриптоПро CSP. -

-
- ) : ( - - - - - ) } - {/**/} - - )} - - ) } - -
-
-
- -
-
- { error && ( - - )} - { !sign_digital && ( -
-
-

- { filename } - Анкета клиента -

- - { downloading ? ( - - ) : "Скачать" } - + { sign.digital && ( + <> + { digital_disabled ? ( +
+ + + +

Внимание + Подписант отличается от Единоличного исполнительного органа. Подписание посредством ЭЦП недоступно. +

+
+ ) : ( + <> + { mobile ? ( +
+ + + +

Внимание + Для подписания анкеты посредством ЭЦП пожалуйста воспользуйтесь стационарным компьютером или ноутбуком с установленной программой КриптоПро CSP. +

+
+ ) : ( + + + + ) } + + )} + + ) } + +
+
+
+ + +
- ) } - - - ); + + { error && ( + + )} + { !sign.digital && ( +
+
+

+ { filename } + Анкета клиента +

+ + { downloading ? ( + + ) : "Скачать" } + +
+
+ ) } + + + ); + } } } diff --git a/components/questionnaire/forms/Form_9_Status/index.js b/components/questionnaire/forms/Form_9_Status/index.js index 59a048a..6c63edb 100644 --- a/components/questionnaire/forms/Form_9_Status/index.js +++ b/components/questionnaire/forms/Form_9_Status/index.js @@ -14,6 +14,7 @@ import QuestionnaireForm from "../QuestionnaireForm"; import { reduxWrapper } from '../../../../store'; import DigitalSignaturesList from "../DigitalSignaturesList"; import { downloadQuestionnaire, uploadSignedFile } from "../../../../actions"; +import FormMessage from "../FormMessage"; class Form_9_Status extends QuestionnaireForm { @@ -26,6 +27,7 @@ class Form_9_Status extends QuestionnaireForm file: null, sent: null, company: {}, + error_file_size: false, }; this.ref_file_input = React.createRef(); @@ -46,26 +48,20 @@ class Form_9_Status extends QuestionnaireForm _handle_onFileUpload = () => { - console.log("_handle_onFileUpload"); - console.log(this.ref_file_input); - this.ref_file_input.current.click(); } _handle_onFileChange = (event) => - { - console.log("_handle_onFileChange"); - console.log(event); - console.log("file", file); - + { const file = event.target.files[0]; - this.setState({ file: file }); + + const error_file_size = file.size > ( 1024 * 1024 * process.env.NEXT_PUBLIC_UPLOAD_SCAN_FILESIZE_LIMIT_MB) ? true : false; + this.setState({ file: file, error_file_size, filename: file.name }); } _handle_onSend = () => { const { file, company, uploading } = this.state; - console.log("company", company); if(!uploading) { @@ -89,48 +85,36 @@ class Form_9_Status extends QuestionnaireForm render() { - const { sign, file, uploading, sent } = this.state; - console.log( {sign} ); + const { sign, file, uploading, sent, error_file_size, filename } = this.state; + console.log("Form_9_Status", "render", { sign }); return ( { sign.digital && ( -
- - - - -

- Анкета заполнена и подписана - Вы заполнили и подписали анкету лизингополучателя посредством - ЭЦП. Анкета передана в обрабатывающий центр. Если у - сотрудников возникнут вопросы мы свяжемся с Вами. Спасибо! -

-
+
) } - { sign.print && ( + { !sign.digital && ( + { file === null ? ( -
- - - - -

- Анкета заполнена и ожидает вашего подписания - Вы заполнили анкету лизингополучателя для подписания в режиме загрузки скана анкеты. Пожалуйста, загрузите скан подписанной анкеты. -

-
+
<> -
@@ -138,16 +122,20 @@ class Form_9_Status extends QuestionnaireForm { !sent ? ( -
- - - - -

- Анкета заполнена, подписана и ожидает отправки - Вы заполнили и подписали анкету лизингополучателя в режиме загрузки скана анкеты. Пожалуйста, отправьте подписанный документ. -

-
+ { error_file_size ? ( + + ) : ( + + ) }
@@ -155,30 +143,26 @@ class Form_9_Status extends QuestionnaireForm { file.name } Подписанный скан анкеты

- + { error_file_size ? ( + + ) : ( + + ) }
) : ( -
- - - - -

- Анкета заполнена и подписана - Вы заполнили и подписали анкету лизингополучателя посредством - загрузки скана анкеты. Анкета передана в обрабатывающий центр. - Если у сотрудников возникнут вопросы мы свяжемся с Вами. - Спасибо! -

-
+
diff --git a/components/questionnaire/forms/QuestionnaireForm.js b/components/questionnaire/forms/QuestionnaireForm.js index ed529dc..a347d71 100644 --- a/components/questionnaire/forms/QuestionnaireForm.js +++ b/components/questionnaire/forms/QuestionnaireForm.js @@ -211,6 +211,7 @@ export default class QuestionnaireForm extends React.Component questionnaireSetSign({ dispatch, sign: { digital: true, print: false, }}); setTimeout(() => { + this.props.onSuccess(); this.props.onNextStep("status"); }, 10); } diff --git a/pages/questionnaire/index.js b/pages/questionnaire/index.js index 4b5b6b2..2d20ce6 100644 --- a/pages/questionnaire/index.js +++ b/pages/questionnaire/index.js @@ -67,11 +67,13 @@ class QuestionnairePage extends React.Component _init = () => { + console.log("_init"); const { company } = this.state; const { dispatch } = this.props; console.log("-".repeat(50)); console.log(company); + getQuestionnaire({ dispatch, id: company.questionnaire_id }) .then(() => { @@ -105,6 +107,7 @@ class QuestionnairePage extends React.Component _handle_onSuccess = () => { + console.log("_handle_onSuccess"); getCompanyInfo({ dispatch: this.props.dispatch }); defaultQuestionnaire({ dispatch: this.props.dispatch }); } diff --git a/reducers/initialState.js b/reducers/initialState.js index 1ac16b8..dedc8cf 100644 --- a/reducers/initialState.js +++ b/reducers/initialState.js @@ -120,8 +120,7 @@ export const questionnaire_template = { }, personal_data_consent: true, sign: { - digital: false, - print: true, + digital: true, uploading: false, uploaded: false, sent: false,