diff --git a/actions/questionnaireActions.js b/actions/questionnaireActions.js index 2c644bc..64733c3 100644 --- a/actions/questionnaireActions.js +++ b/actions/questionnaireActions.js @@ -248,6 +248,33 @@ export const uploadAttachmentFile = (file) => }); } +export const uploadSignedFile = (file, id) => +{ + return new Promise((resolve, reject) => + { + let data = new FormData(); + data.append('file', file); + data.append('id', id); + + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/send`, data, + { + headers: { + "Content-Type": "multipart/form-data; charset=utf-8", + }, + withCredentials: true, + }) + .then(async (response) => + { + resolve(response.data); + }) + .catch((error) => + { + console.error(error); + reject(); + }); + }); +} + export const removeAttachmentFiles = (files) => { for(let i in files) @@ -282,7 +309,7 @@ export const removeAttachmentFile = (id) => }); } -export const downloadQuestionnaire = (download = true) => +export const downloadQuestionnaire = ({ filename, download = true }) => { console.log("ACTION", "questionnaireActions", "downloadQuestionnaire()", ); @@ -306,7 +333,7 @@ export const downloadQuestionnaire = (download = true) => }) */ - axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/download`, { questionnaire: playload }, { + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/download`, { questionnaire: playload, filename }, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/pdf' @@ -318,13 +345,13 @@ export const downloadQuestionnaire = (download = true) => if(download) { console.log("downloadQuestionnaire", "response.data"); - fileDownload(response.data, response.headers.filename); + fileDownload(response.data, filename); resolve(); } else { - resolve({ file: response.data, filename: response.headers.filename }); + resolve({ file: response.data, filename }); } //dispatch({ type: actionTypes.SUPPORT_APPEALS, data: { appeals: { list: response.data.appeals, new: response.data.new, } } }); diff --git a/components/CalendarDatePicker/index.js b/components/CalendarDatePicker/index.js index 11fd763..c8896ef 100644 --- a/components/CalendarDatePicker/index.js +++ b/components/CalendarDatePicker/index.js @@ -90,9 +90,11 @@ export default class CalendarDatePicker extends React.Component render() { - const { id, placeholder, value, min, max, disabled, plain, style } = this.props; + const { id, placeholder, value, min, max, disabled, plain, style, required, className } = this.props; const { readonly, input_value } = this.state; + console.log("DATE", className); + if(disabled) { return ( @@ -114,6 +116,7 @@ export default class CalendarDatePicker extends React.Component min={ min } max={ max } onChange={ this._handle_onChange } + inputProps={{ required }} />
{ event.stopPropagation(); event.preventDefault(); } }/> @@ -124,7 +127,7 @@ export default class CalendarDatePicker extends React.Component else { return ( -
+
) diff --git a/components/questionnaire/SuggestsInput.js b/components/questionnaire/SuggestsInput.js index df83ab9..82d127b 100644 --- a/components/questionnaire/SuggestsInput.js +++ b/components/questionnaire/SuggestsInput.js @@ -155,14 +155,14 @@ export default class SuggestsInput extends React.Component render() { const { focused, options } = this.state; - const { value, disabled, required, placeholder, name } = this.props; + const { value, disabled, required, placeholder, name, className } = this.props; return (
{ - downloadQuestionnaire(false) + downloadQuestionnaire({ download: false }) .then(({ file, filename }) => { //let created_at = moment().format('DD-MM-yyyy'); diff --git a/components/questionnaire/forms/Form_2_Contacts/index.js b/components/questionnaire/forms/Form_2_Contacts/index.js index 9e6937a..ac310a2 100644 --- a/components/questionnaire/forms/Form_2_Contacts/index.js +++ b/components/questionnaire/forms/Form_2_Contacts/index.js @@ -38,7 +38,6 @@ class Form_2_Contacts extends QuestionnaireForm fias_id: null, }, }, - step: 1, }; } diff --git a/components/questionnaire/forms/Form_3_Signer/index.js b/components/questionnaire/forms/Form_3_Signer/index.js index fdee5e8..37d8a37 100644 --- a/components/questionnaire/forms/Form_3_Signer/index.js +++ b/components/questionnaire/forms/Form_3_Signer/index.js @@ -17,6 +17,8 @@ import FilesList from "../FilesList"; import Modal from "../../../../pages/components/Modal/modal"; import countries from "../../../../lib/countries.json"; import citizenships from "../../../../lib/citizenships.json"; +import doctypes_personal from "../../../../lib/doctypes_personal.json"; +import doctypes_corporate from "../../../../lib/doctypes_corporate.json"; import { reduxWrapper } from '../../../../store'; import moment from "moment"; import AddressSuggests from "../../AddressSuggests"; @@ -117,13 +119,15 @@ class Form_3_Signer extends QuestionnaireForm delegation_files: [], head_person_files: [], signatory_person_files: [], - - personal_data_consent: false, + signatory_corporate_files: [], loading: false, modal_show_personal_data: false, - step: 1, status: "empty", + errors: [], }; + + this.ref_form = React.createRef(); + this.ref_submit = React.createRef(); } static getDerivedStateFromProps(nextProps, prevState) @@ -135,12 +139,18 @@ class Form_3_Signer extends QuestionnaireForm delegation_files: nextProps.questionnaire.delegation_files, signatory_person: nextProps.questionnaire.signatory_person, signatory_person_files: nextProps.questionnaire.signatory_person_files, + signatory_corporate_files: nextProps.questionnaire.signatory_corporate_files, status: nextProps.questionnaire.status, }; } componentDidMount() { + const { main } = this.state; + if( main.inn !== null && main.inn.length === 12) + { + this._handle_onCheckboxFieldChange("head_person.evo_indefinite", true); + } } _handle_onCitizenshipChange = (name, value) => @@ -193,21 +203,12 @@ class Form_3_Signer extends QuestionnaireForm } } - _handle_onFormSubmit = (event) => + _handle_onNextPage = (event) => { + console.log("Form_3_Signer", "_handle_onNextPage"); event.preventDefault(); - console.log("Form_3_Signer", "_handle_onFormSubmit"); - this._handle_onCheckboxFieldChange("step", 4); - setTimeout(() => - { - saveQuestionnaire(); - this.props.onNextStep("shareholders"); - }, 10); - } - - _checkDisabled = () => - { + const errors = []; const { main, head_person, signatory_person, } = this.state; const head_person_check = [ @@ -229,17 +230,21 @@ class Form_3_Signer extends QuestionnaireForm for(let i in head_person_check) { - if(_get(head_person, head_person_check[i]) === "") + let v = _get(head_person, head_person_check[i]); + + if(v === "" || v === null) { - return true; + errors.push(`head_person.${ head_person_check[i] }`); } } + console.log({ errors }); + if(!head_person.evo_indefinite) { if(head_person.evo_credentials_dateend === "") { - return true; + errors.push(`head_person.evo_credentials_dateend`); } } @@ -256,9 +261,11 @@ class Form_3_Signer extends QuestionnaireForm for(let i in main_check) { - if(_get(main, main_check[i]) === "") + let v = _get(main, main_check[i]); + + if(v === "" || v === null) { - return true; + errors.push(`main.${ main_check[i] }`); } } } @@ -271,9 +278,6 @@ class Form_3_Signer extends QuestionnaireForm "firstname", "jobtitle", "signer_rule_basis", - "signer_rule_basis_add", - "docdate", - "docnumber", "telephone", "email", "identity_document.seria", @@ -286,40 +290,58 @@ class Form_3_Signer extends QuestionnaireForm "identity_document.registration_address.title", ]; + if(signatory_person.signer_rule_basis === 100000003) + { + signatory_person_check.push("signer_rule_basis_add"); + } + + if(signatory_person.signer_rule_basis === 100000001 || signatory_person.signer_rule_basis === 100000003) + { + signatory_person_check.push("docdate"); + signatory_person_check.push("docnumber"); + } + for(let i in signatory_person_check) { - if(_get(signatory_person, signatory_person_check[i]) === "") + let v = _get(signatory_person, signatory_person_check[i]); + + if(v === "" || v === null) { - return true; + errors.push(`signatory_person.${ signatory_person_check[i] }`); } - } - } - - return false; - } - - /* - _checkDisabled = () => - { - const { main } = this.state; - const check = ["high_level", "board_of_directors", "collective_executive", "individual_executive"]; - - for(let i in check) - { - if(main[check[i]] === "") - { - return true; } } - if(!main.accept) + this.setState({ errors }, () => { - return true; - } - - return false; + this.ref_submit.current.click(); + }); + //this.ref_form.current.submit(); + //this.ref_form.current.dispatchEvent(new Event('submit', { cancelable: true })); + } + + _removeError = (name) => + { + const errors = [ ...this.state.errors ]; + if(errors.indexOf(name) > -1) + { + errors.splice(errors.indexOf(name), 1); + } + this.setState({ errors }); + } + + _handle_onFormSubmit = (event) => + { + event.preventDefault(); + console.log("Form_3_Signer", "_handle_onFormSubmit"); + + this._handle_onCheckboxFieldChange("step", 4); + setTimeout(() => + { + saveQuestionnaire(); + this.props.onNextStep("shareholders"); + }, 10); } - */ render() { @@ -328,31 +350,37 @@ class Form_3_Signer extends QuestionnaireForm personal_data_consent, head_person_files, signatory_person_files, + signatory_corporate_files, delegation_files, modal_show_personal_data, + errors, } = this.state; console.log("delegation_files", delegation_files); + const { loading, } = this.state; const { main, head_person, signatory_person, status } = this.state; + + console.log("head_person.evo_assignment_date", head_person.evo_assignment_date); let head_person_citizenship = { label: getCitizenshipTitleByCode(head_person.identity_document.citizenship.code), code: head_person.identity_document.citizenship.code }; let signatory_person_citizenship = { label: getCitizenshipTitleByCode(signatory_person.identity_document.citizenship.code), code: signatory_person.identity_document.citizenship.code }; return ( -
+ {if (e.key === 'Enter') e.preventDefault() }}>

3. Информация о единоличном исполнительном органе, подписанте договора лизинга

-1 ? "error" : "" } type="lastname" id="head_person.lastname" name="head_person.lastname" value={ this._checkStrValue(head_person.lastname) } placeholder="Введите фамилию" - onChange={ (value) => this._handle_onTextFieldChange("head_person.lastname", value) } + onChange={ (value) => { this._removeError("head_person.lastname"); this._handle_onTextFieldChange("head_person.lastname", value); } } required={ true } disabled={ checking } /> @@ -371,12 +399,13 @@ class Form_3_Signer extends QuestionnaireForm
-1 ? "error" : "" } type="firstname" id="head_person.firstname" name="head_person.firstname" value={ this._checkStrValue(head_person.firstname) } placeholder="Введите имя" - onChange={ (value) => this._handle_onTextFieldChange("head_person.firstname", value) } + onChange={ (value) => { this._removeError("head_person.firstname"); this._handle_onTextFieldChange("head_person.firstname", value) } } required={ true } disabled={ checking } /> @@ -395,12 +424,13 @@ class Form_3_Signer extends QuestionnaireForm
-1 ? "error" : "" } + type="middlename" id="head_person.middlename" name="head_person.middlename" value={ this._checkStrValue(head_person.middlename) } placeholder="Введите отчество" - onChange={ (value) => this._handle_onTextFieldChange("head_person.middlename", value) } + onChange={ (value) => { this._removeError("head_person.middlename"); this._handle_onTextFieldChange("head_person.middlename", value) } } required={ false } disabled={ checking } /> @@ -415,17 +445,35 @@ class Form_3_Signer extends QuestionnaireForm /> {*/}
+
+ + this._handle_onTextFieldChange(event.target.name, event.target.value) } - required={ true } - disabled={ checking } - /> - {*/}
@@ -489,7 +527,7 @@ class Form_3_Signer extends QuestionnaireForm name="head_person.identity_document.issueby" value={ this._checkStrValue(head_person.identity_document.issueby) } placeholder="Введите наименование подразделения выдавшего документ" - onChange={ (event) => this._handle_onTextFieldChange(event.target.name, event.target.value) } + onChange={ (event) => { this._removeError("head_person.identity_document.issueby"); this._handle_onTextFieldChange(event.target.name, event.target.value) } } required={ true } disabled={ checking } /> @@ -500,7 +538,7 @@ class Form_3_Signer extends QuestionnaireForm id={ "head_person.identity_document.placebirth" } value={ this._checkStrValue(head_person.identity_document.placebirth) } placeholder="Укажите место рождения" - onChange={ (data) => this._handle_onTextFieldChange("head_person.identity_document.placebirth", data.title) } + onChange={ (data) => { this._removeError("head_person.identity_document.issueby"); this._handle_onTextFieldChange("head_person.identity_document.placebirth", data.title) } } required={ true } disabled={ checking } /> @@ -517,7 +555,7 @@ class Form_3_Signer extends QuestionnaireForm className="autocomlete" classNamePrefix="react-select" value={ head_person_citizenship.code !== null ? head_person_citizenship : undefined } - onChange={ (element) => this._handle_onCitizenshipChange(`head_person.identity_document.citizenship`, element.value) } + onChange={ (element) => { this._removeError("head_person.identity_document.citizenship"); this._handle_onCitizenshipChange(`head_person.identity_document.citizenship`, element.value) } } required={ true } isDisabled={ checking } /> @@ -528,7 +566,7 @@ class Form_3_Signer extends QuestionnaireForm value={ this._checkStrValue(head_person.identity_document.registration_address.name) } fias={ this._checkStrValue(head_person.identity_document.registration_address.fias_id) } placeholder="Укажите адрес регистрации" - onChange={ (data) => this._handle_onTextFieldChange("head_person.identity_document.registration_address", data) } + onChange={ (data) => { this._removeError("head_person.identity_document.registration_address.name"); this._handle_onTextFieldChange("head_person.identity_document.registration_address", data) } } required={ true } disabled={ checking } /> @@ -536,6 +574,7 @@ class Form_3_Signer extends QuestionnaireForm
-1 ? "error" : "" } id="head_person.jobtitle" name="head_person.jobtitle" value={ this._checkStrValue(head_person.jobtitle) } @@ -577,10 +616,11 @@ class Form_3_Signer extends QuestionnaireForm
-1 ? "error" : "" } placeholder="ДД.ММ.ГГГГ" id={ "head_person.evo_assignment_date" } value={ this._checkStrValue(head_person.evo_assignment_date) !== "" ? this._checkStrValue(head_person.evo_assignment_date) : null } - onChange={ (date) => this._handle_onTextFieldChange("head_person.evo_assignment_date", date) } + onChange={ (date) => { this._removeError("head_person.evo_assignment_date"); this._handle_onTextFieldChange("head_person.evo_assignment_date", date) } } required={ true } disabled={ checking } style={{maxWidth: "320px"}} @@ -648,7 +688,7 @@ class Form_3_Signer extends QuestionnaireForm
- +
+
+ + this._handle_onTextFieldChange(event.target.name, event.target.value) } - required={ true } - disabled={ checking } - /> -
- -
- - this._handle_onTextFieldChange(event.target.name, event.target.value) } - required={ true } - disabled={ checking } - /> -
- -
-
- - this._handle_onTextFieldChange(event.target.name, event.target.value) } - required={ true } - disabled={ checking } - /> -
- -
- - this._handle_onTextFieldChange("signatory_person.docdate", date) } - required={ true } - disabled={ checking } - /> -
-
- +

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

+ +
+ + 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) && ( + <> +
+
+ + this._handle_onTextFieldChange(event.target.name, event.target.value) } + required={ true } + disabled={ checking } + /> +
+ +
+ + this._handle_onTextFieldChange("signatory_person.docdate", date) } + required={ true } + disabled={ checking } + /> +
+
+ + + + ) } + {/*}
@@ -1067,11 +1147,12 @@ class Form_3_Signer extends QuestionnaireForm {*/} { !checking && (
- +
- +
+
+ + + +
+ + ) : ( + + { !sent ? ( + +
+ + + + +

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

+
+
+
+
+

+ { file.name } + Подписанный скан анкеты +

+ +
+
+
+
+ ) : ( + +
+ + + + +

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

+
+
+ ) } +
+ )} + + ) } ); } @@ -96,17 +181,8 @@ class Form_9_Status extends QuestionnaireForm function mapStateToProps(state, ownProps) { return { - main: state.questionnaire.main, - legal_address: state.questionnaire.legal_address, - fact_address: state.questionnaire.fact_address, - postal_address: state.questionnaire.postal_address, - head_person: state.questionnaire.head_person, - head_person_files: state.questionnaire.head_person_files, - signatory_person: state.questionnaire.signatory_person, - signatory_person_files: state.questionnaire.signatory_person_files, - founder_persons: state.questionnaire.founder_persons, - client_contacts: state.questionnaire.client_contacts, - non_profit: state.questionnaire.non_profit, + questionnaire: state.questionnaire, + company: state.company, } } diff --git a/css/components/style.css b/css/components/style.css index 07e42fa..ae81485 100644 --- a/css/components/style.css +++ b/css/components/style.css @@ -1 +1,579 @@ -.bx-breadcrumb{display:flex;flex-wrap:wrap;width:100%;max-width:1310px;margin:25px auto -40px auto;position:relative;z-index:2}.bx-breadcrumb .bx-breadcrumb-item{color:rgba(0,0,0,0.5)}.bx-breadcrumb .bx-breadcrumb-item a{text-decoration:none;color:rgba(0,0,0,0.5)}.bx-breadcrumb .bx-breadcrumb-item a:hover{color:#000}.bx-breadcrumb .bx-breadcrumb-item:before{content:"<";display:inline-block;margin:0 4px}@media all and (max-width:1420px){.bx-breadcrumb{width:calc(100% - 160px);margin:25px 80px -40px 80px}}@media all and (max-width:960px){.bx-breadcrumb{margin:25px 80px -25px 80px}}@media all and (max-width:768px){.bx-breadcrumb{margin:12px 16px -25px 16px;width:calc(100% - 32px)}}hr{display:block;width:100%;height:1px;background:#EDEFF5;border:0;margin:20px 0}button,.button{border:0;background:transparent;appearance:none;box-shadow:none;cursor:pointer;box-sizing:border-box;padding:0px 15px;display:inline-flex;align-items:center;justify-content:center;height:40px;font-weight:600;font-size:15px;line-height:20px}@media all and (max-width:1600px){button,.button{font-size:13px}}.button{color:var(--blue);background:#fff}.button:disabled{opacity:.48;cursor:default}.button.icon:before{content:"";display:block;width:16px;height:16px;margin-right:12px}.button.button-blue{background:var(--blue);color:#fff}.button.button-blue.icon:before{background:url("/assets/images/icons/btn_icon_white.svg") no-repeat center}.button.button-blue.transparent{color:var(--blue);background:transparent}.button.button-blue.transparent.icon:before{background:url("/assets/images/icons/btn_icon_blue.svg") no-repeat center}.button.button-gray{color:var(--gray);background:var(--gray-light)}.button.button-gray.transparent{color:var(--gray);background:transparent}.button.button-gray.icon:before{background:url("/assets/images/icons/btn_icon_gray.svg") no-repeat center}.button.button-compact{width:40px;height:40px;text-indent:-9999px;overflow:hidden}.button.button-compact.icon:before{margin-right:0}@media all and (max-width:768px){.button.download-icon{width:24px;height:24px;background:url("/assets/images/icons/download_icon.svg") no-repeat center;overflow:hidden;text-indent:-999px}.button.download-icon svg{color:var(--blue) !important;background:#fff}}.form_field{position:relative}input[type="checkbox"]{display:none;visibility:hidden;position:relative}input[type="checkbox"]+label{cursor:pointer;padding-left:28px;display:block}input[type="checkbox"]+label:before{content:"";display:block;width:16px;min-width:16px;height:16px;border:1px solid rgba(0,16,61,0.12);box-sizing:border-box;border-radius:4px;margin-right:12px;position:absolute;left:0;top:2px}input[type="checkbox"]:checked+label:before{background:url("/assets/images/icons/checkbox_white.svg") no-repeat center var(--primary);border-color:var(--primary)}input[type="checkbox"]:disabled+label{cursor:default}input[type="checkbox"]:disabled+label:before{background:var(--inactive);opacity:.45;cursor:default;border-color:var(--gray-light)}input[type="radio"]{display:none;visibility:hidden}input[type="radio"]+label{display:block;padding-left:28px;cursor:pointer}input[type="radio"]+label:before{content:"";display:block;border:1px solid rgba(0,16,61,0.12);box-sizing:border-box;border-radius:100%;width:16px;min-width:16px;height:16px;position:absolute;left:0;top:2px}input[type="radio"]:checked+label:before{background:#fff;box-shadow:inset 0 0 0 5px #005FF9;border-color:#005FF9;border:0}input[type="radio"]:disabled+label{cursor:default}input[type="radio"]:disabled+label:before{background:var(--inactive);cursor:default}.selected_item{display:flex;align-items:center;justify-content:center;background:var(--gray-light);box-sizing:border-box;padding:0 2px}.selected_item img{width:24px;height:24px;object-fit:cover;object-position:center;margin-right:8px}.selected_item .delete{margin-left:8px;width:28px;height:28px;background:url("/assets/images/icons/delete_gray.svg") no-repeat center}.list-column{column-gap:20px;list-style:disc;margin:15px 0 15px 20px}.list-column li{line-height:25px}.list-column[data-column="2"]{column-count:2}@media all and (max-width:768px){.list-column[data-column="2"]{column-count:1}}.list-column[data-column="3"]{column-count:3}@media all and (max-width:768px){.list-column[data-column="3"]{column-count:1}}.form_field{position:relative}.form_field .clear{position:absolute;top:0;right:0;width:40px;height:40px;background:url("/assets/images/icons/delete_black.svg") no-repeat center;z-index:2}.form_field.error input,.form_field.error textarea,.form_field.error select{border-color:#FFADAD;margin-bottom:30px !important}.form_field.error:after{content:attr(data-error);display:block;font-size:11px;line-height:15px;color:#FFADAD;position:absolute;left:0;bottom:12px}@media all and (max-width:1600px){.form_field.error:after{font-size:9px}}.form_field input,.form_field textarea,.form_field select{border:1px solid rgba(0,16,61,0.12);box-sizing:border-box;height:40px;background:#fff;padding:0 12px;width:100%;outline:none;font-family:'Montserrat',sans-serif;font-size:1rem}.form_field input::placeholder,.form_field textarea::placeholder,.form_field select::placeholder{font-size:15px;line-height:24px;color:#919399;font-family:'Montserrat',sans-serif;font-weight:400}.form_field input.error,.form_field textarea.error,.form_field select.error{border-color:var(--red)}.form_field input.filled,.form_field textarea.filled,.form_field select.filled{border-color:rgba(0,16,61,0.48)}.form_field input:disabled,.form_field textarea:disabled,.form_field select:disabled{background:var(--gray-light)}.form_field input[type="search"],.form_field textarea[type="search"],.form_field select[type="search"]{padding-left:32px;background-image:url("/assets/images/icons/icon-search.svg");background-repeat:no-repeat;background-position:8px 50%}.form_field input[type="date"],.form_field textarea[type="date"],.form_field select[type="date"],.form_field input.date_input,.form_field textarea.date_input,.form_field select.date_input{padding-left:32px;background-image:url("/assets/images/icons/icon-date.svg");background-repeat:no-repeat;background-position:8px 50%}.form_field input[type="date"]::-webkit-inner-spin-button,.form_field textarea[type="date"]::-webkit-inner-spin-button,.form_field select[type="date"]::-webkit-inner-spin-button,.form_field input.date_input::-webkit-inner-spin-button,.form_field textarea.date_input::-webkit-inner-spin-button,.form_field select.date_input::-webkit-inner-spin-button,.form_field input[type="date"]::-webkit-calendar-picker-indicator,.form_field textarea[type="date"]::-webkit-calendar-picker-indicator,.form_field select[type="date"]::-webkit-calendar-picker-indicator,.form_field input.date_input::-webkit-calendar-picker-indicator,.form_field textarea.date_input::-webkit-calendar-picker-indicator,.form_field select.date_input::-webkit-calendar-picker-indicator{display:none;-webkit-appearance:none}@media all and (max-width:1600px) and (min-width:1280px){.form_field input,.form_field textarea,.form_field select{font-size:14px}.form_field input::placeholder,.form_field textarea::placeholder,.form_field select::placeholder{font-size:14px}}@media all and (max-width:960px){.form_field input,.form_field textarea,.form_field select{font-size:13px}}.form_field select{background-image:url("/assets/images/icons/icon-select.svg");background-repeat:no-repeat;background-position:calc(100% - 16px) 50%;-webkit-appearance:none;-moz-appearance:none}.form_field select::-ms-expand{display:none}.form_field textarea{padding-top:10px;height:80px}.fieldgroup{display:flex;justify-content:space-between}.socials{display:flex}.socials a{display:block;width:32px;height:32px;text-decoration:none}.socials a:not(:last-child){margin-right:22px}@media all and (max-width:1279px){.socials a:not(:last-child){margin-right:6px}}.tabs{display:flex}.tabs .tab{line-height:40px;margin-right:8px;padding:0 20px;cursor:pointer}.tabs .tab.active{background:var(--blue);color:#fff;font-weight:700;cursor:default}@media all and (max-width:960px){.tabs .tab{font-size:10px;line-height:35px}.tabs .tab.active{font-weight:400}}@media all and (max-width:768px){.tabs .tab{margin-right:0;padding:0 16px}}.pagination{margin-top:40px}@media all and (max-width:1600px) and (min-width:1280px){.pagination{margin-top:20px}}.pagination ul{display:flex;align-items:flex-end;justify-content:flex-end}.pagination ul li{font-size:26px;line-height:35px;color:var(--blue)}@media all and (max-width:1600px) and (min-width:1280px){.pagination ul li{font-size:20px;line-height:30px}}.pagination ul li a{display:block;padding:0 5px}@media all and (max-width:1279px){.pagination ul{justify-content:center}.pagination ul li{font-size:13px;line-height:28px;min-width:30px}.pagination ul li a{text-align:center;font-weight:600}}.image-full{width:100%;margin-bottom:50px;height:450px;background:var(--gray-light)}.image-full img{width:100%;height:100%;object-fit:cover}ul.custom-dots{list-style:none;padding:0}ul.custom-dots li{padding-left:15px;position:relative}ul.custom-dots li:before{content:"";display:block;position:absolute;width:2px;height:2px;background:#000;border-radius:2px;top:9px;left:5px}.date_input_wrapper{position:relative}.date_input_wrapper .rw-widget-picker{border:1px solid rgba(0,16,61,0.12) !important;box-shadow:none !important;box-sizing:border-box;height:40px;background:#fff;border-radius:0;width:100%;outline:none;font-size:15px}.date_input_wrapper .rw-widget-input{padding:0 12px 0 32px;outline:none;box-shadow:none !important;border:0}@media all and (max-width:768px){.date_input_wrapper .rw-widget-input{margin-top:0}}.date_input_wrapper .rw-input-addon.rw-picker-btn{border:0;width:100%;background-image:url("/assets/images/icons/icon-date.svg");background-repeat:no-repeat;background-position:8px 50%;position:absolute;top:0;left:0;height:40px}.date_input_wrapper .rw-input-addon.rw-picker-btn:hover{background-color:transparent}.date_input_wrapper .rw-input-addon.rw-picker-btn svg{display:none}.custom-multi-select .custom-select__control{min-height:40px;border-radius:0;border:1px solid rgba(0,16,61,0.12) !important;background:#fff;box-shadow:unset !important}.custom-multi-select .custom-select__control .custom-select__control{margin:0}.custom-multi-select .custom-select__control .custom-select__value-container{padding:2px 12px}.custom-multi-select .custom-select__control .custom-select__input-container{margin-top:0;min-height:38px}.custom-multi-select .custom-select__control .custom-select__multi-value{margin-top:0}/*# sourceMappingURL=./style.css.map */ \ No newline at end of file +.bx-breadcrumb { + display: flex; + flex-wrap: wrap; + width: 100%; + max-width: 1310px; + margin: 25px auto -40px auto; + position: relative; + z-index: 2; +} +.bx-breadcrumb .bx-breadcrumb-item { + color: rgba(0, 0, 0, 0.5); +} +.bx-breadcrumb .bx-breadcrumb-item a { + text-decoration: none; + color: rgba(0, 0, 0, 0.5); +} +.bx-breadcrumb .bx-breadcrumb-item a:hover { + color: #000; +} +.bx-breadcrumb .bx-breadcrumb-item:before { + content: "<"; + display: inline-block; + margin: 0 4px; +} +@media all and (max-width: 1420px) { + .bx-breadcrumb { + width: calc(100% - 160px); + margin: 25px 80px -40px 80px; + } +} +@media all and (max-width: 960px) { + .bx-breadcrumb { + margin: 25px 80px -25px 80px; + } +} +@media all and (max-width: 768px) { + .bx-breadcrumb { + margin: 12px 16px -25px 16px; + width: calc(100% - 32px); + } +} +hr { + display: block; + width: 100%; + height: 1px; + background: #EDEFF5; + border: 0; + margin: 20px 0; +} +button, +.button { + border: 0; + background: transparent; + appearance: none; + box-shadow: none; + cursor: pointer; + box-sizing: border-box; + padding: 0px 15px; + display: inline-flex; + align-items: center; + justify-content: center; + height: 40px; + font-weight: 600; + font-size: 15px; + line-height: 20px; +} +@media all and (max-width: 1600px) { + button, + .button { + font-size: 13px; + } +} +.button { + color: var(--blue); + background: #fff; +} +.button:disabled { + opacity: 0.48; + cursor: default; +} +.button.icon:before { + content: ""; + display: block; + width: 16px; + height: 16px; + margin-right: 12px; +} +.button.button-blue { + background: var(--blue); + color: #fff; +} +.button.button-blue.icon:before { + background: url("/assets/images/icons/btn_icon_white.svg") no-repeat center; +} +.button.button-blue.transparent { + color: var(--blue); + background: transparent; +} +.button.button-blue.transparent.icon:before { + background: url("/assets/images/icons/btn_icon_blue.svg") no-repeat center; +} +.button.button-gray { + color: var(--gray); + background: var(--gray-light); +} +.button.button-gray.transparent { + color: var(--gray); + background: transparent; +} +.button.button-gray.icon:before { + background: url("/assets/images/icons/btn_icon_gray.svg") no-repeat center; +} +.button.button-compact { + width: 40px; + height: 40px; + text-indent: -9999px; + overflow: hidden; +} +.button.button-compact.icon:before { + margin-right: 0; +} +@media all and (max-width: 768px) { + .button.download-icon { + width: 24px; + height: 24px; + background: url("/assets/images/icons/download_icon.svg") no-repeat center; + overflow: hidden; + text-indent: -999px; + } + .button.download-icon svg { + color: var(--blue) !important; + background: #fff; + } +} +.form_field { + position: relative; +} +input[type="checkbox"] { + display: none; + visibility: hidden; + position: relative; +} +input[type="checkbox"] + label { + cursor: pointer; + padding-left: 28px; + display: block; +} +input[type="checkbox"] + label:before { + content: ""; + display: block; + width: 16px; + min-width: 16px; + height: 16px; + border: 1px solid rgba(0, 16, 61, 0.12); + box-sizing: border-box; + border-radius: 4px; + margin-right: 12px; + position: absolute; + left: 0; + top: 2px; +} +input[type="checkbox"]:checked + label:before { + background: url("/assets/images/icons/checkbox_white.svg") no-repeat center var(--primary); + border-color: var(--primary); +} +input[type="checkbox"]:disabled + label { + cursor: default; +} +input[type="checkbox"]:disabled + label:before { + background: var(--inactive); + opacity: 0.45; + cursor: default; + border-color: var(--gray-light); +} +input[type="radio"] { + display: none; + visibility: hidden; +} +input[type="radio"] + label { + display: block; + padding-left: 28px; + cursor: pointer; +} +input[type="radio"] + label:before { + content: ""; + display: block; + border: 1px solid rgba(0, 16, 61, 0.12); + box-sizing: border-box; + border-radius: 100%; + width: 16px; + min-width: 16px; + height: 16px; + position: absolute; + left: 0; + top: 2px; +} +input[type="radio"]:checked + label:before { + background: #fff; + box-shadow: inset 0px 0 0px 5px #005FF9; + border-color: #005FF9; + border: 0; +} +input[type="radio"]:disabled + label { + cursor: default; +} +input[type="radio"]:disabled + label:before { + background: var(--inactive); + cursor: default; +} +.selected_item { + display: flex; + align-items: center; + justify-content: center; + background: var(--gray-light); + box-sizing: border-box; + padding: 0 2px; +} +.selected_item img { + width: 24px; + height: 24px; + object-fit: cover; + object-position: center; + margin-right: 8px; +} +.selected_item .delete { + margin-left: 8px; + width: 28px; + height: 28px; + background: url("/assets/images/icons/delete_gray.svg") no-repeat center; +} +.list-column { + column-gap: 20px; + list-style: disc; + margin: 15px 0 15px 20px; +} +.list-column li { + line-height: 25px; +} +.list-column[data-column="2"] { + column-count: 2; +} +@media all and (max-width: 768px) { + .list-column[data-column="2"] { + column-count: 1; + } +} +.list-column[data-column="3"] { + column-count: 3; +} +@media all and (max-width: 768px) { + .list-column[data-column="3"] { + column-count: 1; + } +} +.form_field { + position: relative; +} +.form_field .clear { + position: absolute; + top: 0; + right: 0; + width: 40px; + height: 40px; + background: url("/assets/images/icons/delete_black.svg") no-repeat center; + z-index: 2; +} +.form_field.error input, +.form_field.error textarea, +.form_field.error select { + border-color: #FFADAD; + margin-bottom: 30px !important; +} +.form_field.error:after { + content: attr(data-error); + display: block; + font-size: 11px; + line-height: 15px; + color: #FFADAD; + position: absolute; + left: 0; + bottom: 12px; +} +@media all and (max-width: 1600px) { + .form_field.error:after { + font-size: 9px; + } +} +.form_field input, +.form_field textarea, +.form_field select { + border: 1px solid rgba(0, 16, 61, 0.12); + box-sizing: border-box; + height: 40px; + background: #fff; + padding: 0 12px; + width: 100%; + outline: none; + font-family: 'Montserrat', sans-serif; + font-size: 1rem; +} +.form_field input::placeholder, +.form_field textarea::placeholder, +.form_field select::placeholder { + font-size: 15px; + line-height: 24px; + color: #919399; + font-family: 'Montserrat', sans-serif; + font-weight: 400; +} +.form_field input.error, +.form_field textarea.error, +.form_field select.error { + border-color: var(--red) !important; +} +.form_field input.filled, +.form_field textarea.filled, +.form_field select.filled { + border-color: rgba(0, 16, 61, 0.48); +} +.form_field input:disabled, +.form_field textarea:disabled, +.form_field select:disabled { + background: var(--gray-light); +} +.form_field input[type="search"], +.form_field textarea[type="search"], +.form_field select[type="search"] { + padding-left: 32px; + background-image: url("/assets/images/icons/icon-search.svg"); + background-repeat: no-repeat; + background-position: 8px 50%; +} +.form_field input[type="date"], +.form_field textarea[type="date"], +.form_field select[type="date"], +.form_field input.date_input, +.form_field textarea.date_input, +.form_field select.date_input { + padding-left: 32px; + background-image: url("/assets/images/icons/icon-date.svg"); + background-repeat: no-repeat; + background-position: 8px 50%; +} +.form_field input[type="date"]::-webkit-inner-spin-button, +.form_field textarea[type="date"]::-webkit-inner-spin-button, +.form_field select[type="date"]::-webkit-inner-spin-button, +.form_field input.date_input::-webkit-inner-spin-button, +.form_field textarea.date_input::-webkit-inner-spin-button, +.form_field select.date_input::-webkit-inner-spin-button, +.form_field input[type="date"]::-webkit-calendar-picker-indicator, +.form_field textarea[type="date"]::-webkit-calendar-picker-indicator, +.form_field select[type="date"]::-webkit-calendar-picker-indicator, +.form_field input.date_input::-webkit-calendar-picker-indicator, +.form_field textarea.date_input::-webkit-calendar-picker-indicator, +.form_field select.date_input::-webkit-calendar-picker-indicator { + display: none; + -webkit-appearance: none; +} +@media all and (max-width: 1600px) and (min-width: 1280px) { + .form_field input, + .form_field textarea, + .form_field select { + font-size: 14px; + } + .form_field input::placeholder, + .form_field textarea::placeholder, + .form_field select::placeholder { + font-size: 14px; + } +} +@media all and (max-width: 960px) { + .form_field input, + .form_field textarea, + .form_field select { + font-size: 13px; + } +} +.form_field select { + background-image: url("/assets/images/icons/icon-select.svg"); + background-repeat: no-repeat; + background-position: calc(100% - 16px) 50%; + -webkit-appearance: none; + -moz-appearance: none; +} +.form_field select::-ms-expand { + display: none; +} +.form_field textarea { + padding-top: 10px; + height: 80px; +} +.fieldgroup { + display: flex; + justify-content: space-between; +} +.socials { + display: flex; +} +.socials a { + display: block; + width: 32px; + height: 32px; + text-decoration: none; +} +.socials a:not(:last-child) { + margin-right: 22px; +} +@media all and (max-width: 1279px) { + .socials a:not(:last-child) { + margin-right: 6px; + } +} +.tabs { + display: flex; +} +.tabs .tab { + line-height: 40px; + margin-right: 8px; + padding: 0 20px; + cursor: pointer; +} +.tabs .tab.active { + background: var(--blue); + color: #fff; + font-weight: 700; + cursor: default; +} +@media all and (max-width: 960px) { + .tabs .tab { + font-size: 10px; + line-height: 35px; + } + .tabs .tab.active { + font-weight: 400; + } +} +@media all and (max-width: 768px) { + .tabs .tab { + margin-right: 0; + padding: 0 16px; + } +} +.pagination { + margin-top: 40px; +} +@media all and (max-width: 1600px) and (min-width: 1280px) { + .pagination { + margin-top: 20px; + } +} +.pagination ul { + display: flex; + align-items: flex-end; + justify-content: flex-end; +} +.pagination ul li { + font-size: 26px; + line-height: 35px; + color: var(--blue); +} +@media all and (max-width: 1600px) and (min-width: 1280px) { + .pagination ul li { + font-size: 20px; + line-height: 30px; + } +} +.pagination ul li a { + display: block; + padding: 0 5px; +} +@media all and (max-width: 1279px) { + .pagination ul { + justify-content: center; + } + .pagination ul li { + font-size: 13px; + line-height: 28px; + min-width: 30px; + } + .pagination ul li a { + text-align: center; + font-weight: 600; + } +} +.image-full { + width: 100%; + margin-bottom: 50px; + height: 450px; + background: var(--gray-light); +} +.image-full img { + width: 100%; + height: 100%; + object-fit: cover; +} +ul.custom-dots { + list-style: none; + padding: 0; +} +ul.custom-dots li { + padding-left: 15px; + position: relative; +} +ul.custom-dots li:before { + content: ""; + display: block; + position: absolute; + width: 2px; + height: 2px; + background: #000; + border-radius: 2px; + top: 9px; + left: 5px; +} +.date_input_wrapper { + position: relative; +} +.date_input_wrapper .rw-widget-picker { + border: 1px solid rgba(0, 16, 61, 0.12) !important; + box-shadow: none !important; + box-sizing: border-box; + height: 40px; + background: #fff; + border-radius: 0; + width: 100%; + outline: none; + font-size: 15px; +} +.date_input_wrapper .rw-widget-input { + padding: 0 12px 0 32px; + outline: none; + box-shadow: none !important; + border: 0; +} +@media all and (max-width: 768px) { + .date_input_wrapper .rw-widget-input { + margin-top: 0; + } +} +.date_input_wrapper .rw-input-addon.rw-picker-btn { + border: 0; + width: 100%; + background-image: url("/assets/images/icons/icon-date.svg"); + background-repeat: no-repeat; + background-position: 8px 50%; + position: absolute; + top: 0; + left: 0; + height: 40px; +} +.date_input_wrapper .rw-input-addon.rw-picker-btn:hover { + background-color: transparent; +} +.date_input_wrapper .rw-input-addon.rw-picker-btn svg { + display: none; +} +.custom-multi-select .custom-select__control { + min-height: 40px; + border-radius: 0; + border: 1px solid rgba(0, 16, 61, 0.12) !important; + background: #fff; + box-shadow: unset !important; +} +.custom-multi-select .custom-select__control .custom-select__control { + margin: 0; +} +.custom-multi-select .custom-select__control .custom-select__value-container { + padding: 2px 12px; +} +.custom-multi-select .custom-select__control .custom-select__input-container { + margin-top: 0; + min-height: 38px; +} +.custom-multi-select .custom-select__control .custom-select__multi-value { + margin-top: 0; +} +.error { + border: solid 1px var(--red) !important; +} diff --git a/css/components/style.less b/css/components/style.less index 9c2d3be..05866f2 100644 --- a/css/components/style.less +++ b/css/components/style.less @@ -359,7 +359,7 @@ input[type="radio"] { } &.error { - border-color: var(--red); + border-color: var(--red) !important; } &.filled { @@ -644,4 +644,8 @@ ul.custom-dots { margin-top: 0; } } -} \ No newline at end of file +} + +.error { + border: solid 1px var(--red) !important; +} diff --git a/lib/doctypes_corporate.json b/lib/doctypes_corporate.json new file mode 100644 index 0000000..caeb30b --- /dev/null +++ b/lib/doctypes_corporate.json @@ -0,0 +1,6 @@ +[ + { "label": "Доверенности", "value": 100000000 }, + { "label": "Устава", "value": 100000001 }, + { "label": "Является главой ИП \\ ИН КФХ", "value": 100000002 }, + { "label": "Прочего", "value": 100000003 } +] \ No newline at end of file diff --git a/lib/doctypes_personal.json b/lib/doctypes_personal.json new file mode 100644 index 0000000..a1283a2 --- /dev/null +++ b/lib/doctypes_personal.json @@ -0,0 +1,5 @@ +[ + { "label": "Паспорт гражданина РФ", "value": 100000000 }, + { "label": "Иностранный паспорт", "value": 100000001 }, + { "label": "Вид на жительство", "value": 100000002 } +] \ No newline at end of file diff --git a/package.json b/package.json index a99e082..ad139b7 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "cors": "^2.8.5", "dadata": "^0.0.3", "debounce-promise": "^3.1.2", + "file-type": "^18.2.1", "form-data": "^4.0.0", "ioredis": "^4.28.2", "js-file-download": "^0.4.12", diff --git a/pages/api/questionnaire/download.js b/pages/api/questionnaire/download.js index 585c775..9f45648 100644 --- a/pages/api/questionnaire/download.js +++ b/pages/api/questionnaire/download.js @@ -114,7 +114,7 @@ export default async function handler(req, res) console.log("API", "questionnaire", "get"); console.log(req.body); console.log("-".repeat(50)); - const { questionnaire } = req.body; + const { questionnaire, filename } = req.body; await cors(req, res); @@ -303,11 +303,11 @@ export default async function handler(req, res) const pdfBytes = await pdfDoc.save(); //responseType: 'blob', - //fs.writeFileSync(`${ __dirname }/../../../../../uploads/${ client_jwt_decoded.acc_number }_anketa.pdf`, pdfBytes); + fs.writeFileSync(`${ __dirname }/../../../../../uploads/${ client_jwt_decoded.acc_number }_questionnaire.pdf`, pdfBytes); //res.setHeader('Content-Type', 'application/pdf'); //res.send(pdfBytes); console.log("pdfBytes.size", pdfBytes, pdfBytes.byteLength); - res.setHeader("filename", `${ client_jwt_decoded.acc_number }_anketa.pdf`); + res.setHeader("filename", filename); res.setHeader('Content-Type', 'application/pdf'); res.send(Buffer.from(pdfBytes)); diff --git a/pages/api/questionnaire/file/signed.js b/pages/api/questionnaire/file/signed.js new file mode 100644 index 0000000..90315bb --- /dev/null +++ b/pages/api/questionnaire/file/signed.js @@ -0,0 +1,82 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import fs from 'fs'; +import axios from 'axios'; +import { Cookies } from 'react-cookie'; +import cookie from 'cookie'; +import moment from 'moment'; +import jwt from 'jsonwebtoken'; +import Redis from 'ioredis'; +import md5 from 'md5'; +import { inspect } from 'util'; +import multer from 'multer'; + +import { fileTypeFromBuffer } from "file-type"; +//import { MIMEType } from 'util'; + +import { cors } from '../../../../lib/cors'; + +const storage = multer.memoryStorage(); +const upload = multer({ storage: storage }); + +export default async function handler(req, res) +{ + console.log("API", "questionnaire", "get"); + await cors(req, res); + + return new Promise((resolve) => + { + if(req.headers.cookie !== undefined) + { + const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : ""); + + if(cookies.jwt !== undefined && cookies.jwt !== null) + { + var client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT); + var crm_jwt = jwt.sign({ acc_number: client_jwt_decoded.acc_number }, process.env.JWT_SECRET_CRM, { noTimestamp: true }); + + upload.single("file")(req, {}, async (err) => + { + const { file, body } = req; + + const id = md5(`${ file.buffer }`); + const local_filename = `${ client_jwt_decoded.acc_number }_signed_questionnaire_${ moment().format("YYYY_MM_DD_HH:mm:ss") }`; + console.log("fileTypeFromBuffer", await fileTypeFromBuffer(file.buffer)); + + const file_payload = { + id: id, + name: Buffer.from(file.originalname, 'latin1').toString('utf8'), + filename: local_filename, + }; + + try + { + fs.writeFileSync(`${ __dirname }/../../../../../../uploads/${ local_filename }`, file.buffer); + console.log("multer.upload.single file"); + console.log({ file_payload }); + + res.status(200).json(file_payload); + resolve(); + } + catch(upload_single_error) + { + console.error("upload_single_error"); + console.error(upload_single_error); + res.status(500).send(); + resolve(); + } + }); + } + else + { + res.status(403).send(); + resolve(); + } + } + }); +} + +export const config = { + api: { + bodyParser: false + } +} \ No newline at end of file diff --git a/pages/api/questionnaire/send.js b/pages/api/questionnaire/send.js new file mode 100644 index 0000000..bb77698 --- /dev/null +++ b/pages/api/questionnaire/send.js @@ -0,0 +1,279 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import fs from 'fs'; +import axios from 'axios'; +import { Cookies } from 'react-cookie'; +import cookie from 'cookie'; +import moment from 'moment'; +import jwt from 'jsonwebtoken'; +import FormData from 'form-data'; +import Redis from 'ioredis'; +import md5 from 'md5'; +import { inspect } from 'util'; +import multer from 'multer'; +import { get as _get, pick as _pick } from 'lodash'; +import { eachSeries } from 'async'; + +import { fileTypeFromBuffer } from "file-type"; +//import { MIMEType } from 'util'; + +import { cors } from '../../../lib/cors'; +import RedisClient from '../../../lib/RedisClient'; + +const storage = multer.memoryStorage(); +const upload = multer({ storage: storage }); + +export default async function handler(req, res) +{ + console.log("API", "questionnaire", "send"); + await cors(req, res); + + return new Promise((resolve) => + { + if(req.headers.cookie !== undefined) + { + const cookies = cookie.parse(req.headers?.cookie ? req.headers?.cookie : ""); + + if(cookies.jwt !== undefined && cookies.jwt !== null) + { + var client_jwt_decoded = jwt.verify(cookies.jwt, process.env.JWT_SECRET_CLIENT); + var crm_jwt = jwt.sign({ acc_number: client_jwt_decoded.acc_number }, process.env.JWT_SECRET_CRM, { noTimestamp: true }); + + console.log("JWT", cookies.jwt); + console.log("CRM_JWT", crm_jwt); + + upload.single("file")(req, {}, async (err) => + { + const { file } = req; + const { id } = req.body; + const path = `${ process.env.CRM_API_HOST }/lk/Questionnaire/PreQuestionnaire/`; + + const filetype = await fileTypeFromBuffer(file.buffer); + console.log("fileTypeFromBuffer", filetype); + const local_filename = `${ client_jwt_decoded.acc_number }_signed_questionnaire_${ moment().format("YYYY_MM_DD_HH:mm:ss") }.${ filetype.ext }`; + + const key = md5(`questionnaire_${ client_jwt_decoded.acc_number }`); + const questionnaire = await RedisClient.get(key); + + try + { + fs.writeFileSync(`${ __dirname }/../../../../../uploads/${ local_filename }`, file.buffer); + console.log("multer.upload.single file"); + console.log({ questionnaire }); + + const parsed = JSON.parse(questionnaire); + console.log("parsed"); + console.log(".".repeat(50)); + console.log(inspect(parsed, true, null, true)); + + //const main = _pick(parsed.main, ["title", "inn", "kpp", "email", "telephone", "websiteurl", "financial_loan"]); + + let payload = { ...parsed.main, ...{ head_person: parsed.head_person }, ...{ signatory_person: parsed.signatory_person }, }; + + payload.telephone = payload.telephone.replace(/[^0-9]/g, ''); + payload.individual_executive_inn = payload.individual_executive_inn.replace(/[^0-9]/g, ''); + payload.individual_executive_kpp = payload.individual_executive_kpp.replace(/[^0-9]/g, ''); + payload.individual_executive_docdate = payload.individual_executive_docdate !== null ? moment(payload.individual_executive_docdate).format("YYYY-MM-DD") : null; + + if(payload.head_person.middlename !== "" && payload.head_person.middlename !== null) + { + payload.head_person.no_middle_name = false; + } + else + { + payload.head_person.no_middle_name = true; + } + payload.head_person.identity_document.citizenship_code = payload.head_person.identity_document.citizenship.code; + payload.head_person.telephone = payload.head_person.telephone.replace(/[^0-9]/g, ''); + payload.head_person.identity_document.issuedate = payload.head_person.identity_document.issuedate !== null ? moment(payload.head_person.identity_document.issuedate).format("YYYY-MM-DD") : null; + payload.head_person.evo_assignment_date = payload.head_person.evo_assignment_date !== null ? moment(payload.head_person.evo_assignment_date).format("YYYY-MM-DD") : null; + + if(payload.signatory_person.not_head_person) + { + if(payload.signatory_person.middlename !== "" && payload.signatory_person.middlename !== null) + { + payload.signatory_person.no_middle_name = false; + } + else + { + payload.signatory_person.no_middle_name = true; + } + } + else + { + payload.signatory_person = { ...payload.signatory_person, ..._pick(payload.head_person, [ + "lastname", "firstname", "middlename", "no_middle_name", "jobtitle", "telephone", "email", "identity_document", "evo_assignment_date", "evo_credentials_dateend", "evo_indefinite", + ]) }; + } + payload.signatory_person.identity_document.citizenship_code = payload.signatory_person.identity_document.citizenship.code; + payload.signatory_person.telephone = payload.signatory_person.telephone.replace(/[^0-9]/g, ''); + payload.signatory_person.identity_document.issuedate = payload.signatory_person.identity_document.issuedate !== null ? moment(payload.signatory_person.identity_document.issuedate).format("YYYY-MM-DD") : null; + payload.signatory_person.docdate = payload.signatory_person.docdate !== null ? moment(payload.signatory_person.docdate).format("YYYY-MM-DD") : null; + payload.signatory_person.assignment_date = payload.signatory_person.assignment_date !== null ? moment(payload.signatory_person.assignment_date).format("YYYY-MM-DD") : null; + + const founder_persons = parsed.founder_persons; + + for(let i in founder_persons) + { + founder_persons[i].founder_number = parseInt(i, 10) + 1; + founder_persons[i].telephone = founder_persons[i].telephone.replace(/[^0-9]/g, ''); + founder_persons[i].identity_document.issuedate = founder_persons[i].identity_document.issuedate !== null ? moment(founder_persons[i].identity_document.issuedate).format("YYYY-MM-DD") : null; + + if(founder_persons[i].middlename !== "" && founder_persons[i].middlename !== null) + { + founder_persons[i].no_middle_name = false; + } + else + { + founder_persons[i].no_middle_name = true; + } + } + + payload = { ...payload, ...{ founder_persons }, ...{ + revenue_source_main: parsed.non_profit.fin_source_business, + revenue_source_donat: parsed.non_profit.fin_source_donate, + revenue_source_entrance_fee: parsed.non_profit.fin_source_fees, + revenue_source_other: parsed.non_profit.fin_source_another_description, + foreign_countries_financing: parsed.non_profit.foreign_payers, + purpose_use_la: parsed.non_profit.fin_goals_cars, + purpose_use_lkt: parsed.non_profit.fin_goals_trucks, + purpose_use_gt_sc: parsed.non_profit.fin_goals_special, + } }; + payload.financial_loan = parseFloat(payload.financial_loan.replace(/[^0-9.]/g, '')); + + console.log("=".repeat(50)); + console.log(inspect(payload, true, null, true)); + + /* + for(let i in parsed.main) + { + payload[i] = parsed.main[i] === null ? "" : parsed.main[i]; + } + */ + + console.log(id); + console.log("path", path); + console.log("*".repeat(50)); + console.log(payload); + + const files_to_send = []; + for(let i in parsed.head_person_files) + { + //console.log(parsed.head_person_files[i]); + files_to_send.push({ ...parsed.head_person_files[i], ...{ number: 1, } }) + } + /* + for(let i in parsed.delegation_files) + { + console.log(parsed.delegation_files[i]); + files_to_send.push({ ...parsed.delegation_files[i], ...{ number: 1, } }) + } + */ + for(let i in parsed.signatory_person_files) + { + //console.log(parsed.signatory_person_files[i]); + files_to_send.push({ ...parsed.signatory_person_files[i], ...{ number: 23, } }) + } + for(let i in parsed.signatory_corporate_files) + { + //console.log(parsed.signatory_corporate_files[i]); + files_to_send.push({ ...parsed.signatory_corporate_files[i], ...{ number: 22, } }) + } + + files_to_send.push({ ...{ + name: `${ client_jwt_decoded.acc_number }_questionnaire.pdf`, + filename: `${ client_jwt_decoded.acc_number }_questionnaire.pdf`, + }, ...{ number: 18, } }); + + files_to_send.push({ ...{ + name: local_filename, + filename: local_filename, + }, ...{ number: 161, } }); + + console.log("@".repeat(200)); + console.log(payload); + + axios.put(path, payload, + { + params: { name: id }, + headers: { + "Authorization": `Bearer ${ crm_jwt }`, + "Content-Type": "application/json" + } + } + ) + .then((crm_response) => + { + console.log("crm_response for", path); + console.log(inspect(crm_response.data, true, null, true)); + + eachSeries(files_to_send, (file_entry, callback) => + { + console.log({ file_entry }); + + const file_to_send_data = fs.readFileSync(`${ __dirname }/../../../../../uploads/${ file_entry.filename }`); + const data = new FormData(); + data.append("file", file_to_send_data, file_entry.name); + data.append("entity", "evo_client_questionnaire"); + data.append("documentTypeNumber", file_entry.number); + data.append("name", id); + + axios.post(`${ process.env.CRM_API_HOST }/lk/document/upload/`, data, + { + headers: { + "Content-Type": `multipart/form-data; boundary=${ data._boundary }`, + "Authorization": `Bearer ${ crm_jwt }`, + }, + withCredentials: true, + }) + .then(() => + { + console.log("FILE", file_entry.filename, "SENT"); + callback(); + }) + .catch((crm_file_upload_error) => + { + console.error("crm_file_upload_error", crm_file_upload_error); + callback(); + }); + }, () => + { + res.status(200).send(); + resolve(); + }); + }) + .catch((error) => + { + console.error(error); + console.error("-".repeat(30), "error.response.data:"); + console.error(error.response.data); + + res.status(500).send(); + resolve(); + }); + + //res.status(200).send(); + } + catch(upload_single_error) + { + console.error("upload_single_error"); + console.error(upload_single_error.response.data); + + res.status(500).send(); + resolve(); + } + }); + } + else + { + res.status(403).send(); + resolve(); + } + } + }); +} + +export const config = { + api: { + bodyParser: false + } +} \ No newline at end of file diff --git a/pages/questionnaire/index.js b/pages/questionnaire/index.js index ff9f2fa..ecf7c48 100644 --- a/pages/questionnaire/index.js +++ b/pages/questionnaire/index.js @@ -7,6 +7,7 @@ import { connect } from "react-redux"; import numeral from "numeral"; import pluralize from 'pluralize-ru'; import { SpinnerCircular } from 'spinners-react'; +import NoSSR from "@mpth/react-no-ssr"; import { withRouter } from 'next/router'; import { reduxWrapper } from '../../store'; @@ -104,7 +105,7 @@ class QuestionnairePage extends React.Component if (route.indexOf("#regulatory") > -1) return (); if (route.indexOf("#non-profit") > -1) return (); if (route.indexOf("#check") > -1) return (); - if (route.indexOf("#signing") > -1) return (); + if (route.indexOf("#signing") > -1) return (); if (route.indexOf("#status") > -1) return (); return (); @@ -128,14 +129,16 @@ class QuestionnairePage extends React.Component

Анкета лизингополучателя

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