UPDATE: add trace (log/debug/error) wrapper, fix questionnaire css & logical errors with citizenship

This commit is contained in:
merelendor 2024-03-04 09:47:44 +03:00
parent 0de9b0add6
commit f4b1fbac01
9 changed files with 190 additions and 76 deletions

View File

@ -15,6 +15,7 @@ import QuestionnaireForm from "../QuestionnaireForm";
import { reduxWrapper } from '../../../../store';
import { saveQuestionnaire } from "../../../../actions";
import FormMessage from "../FormMessage";
import { traceDebug } from "../../../../utils";
class Form_1_Main extends QuestionnaireForm
{
@ -150,6 +151,10 @@ class Form_1_Main extends QuestionnaireForm
{
this.ref_submit.current.click();
}
else
{
traceDebug({ errors });
}
});
}

View File

@ -15,6 +15,7 @@ import { reduxWrapper } from '../../../../store';
import AddressSuggests from "../../AddressSuggests";
import { saveQuestionnaire } from "../../../../actions";
import FormMessage from "../FormMessage";
import { traceDebug } from "../../../../utils";
class Form_2_Contacts extends QuestionnaireForm
{
@ -101,7 +102,14 @@ class Form_2_Contacts extends QuestionnaireForm
this.setState({ errors }, () =>
{
window.scroll(0, 0);
if(errors.length === 0)
{
this.ref_submit.current.click();
}
else
{
traceDebug({ errors });
}
});
}

View File

@ -29,6 +29,7 @@ import { getCitizenshipTitleByCode } from "../../../../utils/citizenship";
import { removeAttachmentFiles, saveQuestionnaire, getSuggests, checkDocumentData } from "../../../../actions";
import DocumentIssuerSuggestsInput from "../../DocumentIssuerSuggestsInput";
import FormMessage from "../FormMessage";
import { traceDebug } from "../../../../utils";
const is_valid_inn = (i) =>
{
@ -379,9 +380,6 @@ class Form_3_Signer extends QuestionnaireForm
_handle_onSignerFromListSelect = (contact) =>
{
//console.log(contact);
const signer = { ...JSON.parse(JSON.stringify(signer_template)), ...contact };
if(signer.identity_document === undefined || signer.identity_document === null)
{
@ -418,7 +416,7 @@ class Form_3_Signer extends QuestionnaireForm
"identity_document.docnumber",
"identity_document.issuedate",
"identity_document.placebirth",
"identity_document.citizenship_code",
"identity_document.citizenship.code",
"identity_document.registration_address.name",
/*
Запрос 2024-02-08 на удаление даты назначения и даты окончания полномочий
@ -437,7 +435,7 @@ class Form_3_Signer extends QuestionnaireForm
{
const v = _get(head_person, head_person_check[i]);
if(v === "" || v === null)
if(v === "" || v === null || v === undefined)
{
errors.push(`head_person.${ head_person_check[i] }`);
}
@ -572,7 +570,7 @@ class Form_3_Signer extends QuestionnaireForm
}
else
{
if(v === "" || v === null)
if(v === "" || v === null || v === undefined)
{
errors.push(`main.${ main_check[i] }`);
}
@ -635,7 +633,7 @@ class Form_3_Signer extends QuestionnaireForm
{
let v = _get(signatory_person, signatory_person_check[i]);
if(v === "" || v === null)
if(v === "" || v === null || v === undefined)
{
errors.push(`signatory_person.${ signatory_person_check[i] }`);
}
@ -677,6 +675,10 @@ class Form_3_Signer extends QuestionnaireForm
{
this.ref_submit.current.click();
}
else
{
traceDebug({ errors });
}
});
});
}
@ -705,8 +707,6 @@ class Form_3_Signer extends QuestionnaireForm
client_contacts,
} = this.state;
//console.log({ errors });
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 };
@ -876,7 +876,7 @@ class Form_3_Signer extends QuestionnaireForm
</div>
{ parseInt(head_person.identity_document.doctype, 10) !== 100000000 && (
<div className="form_field">
<div className="form_field" style={{ zIndex: 10 }}>
<label>Гражданство <sup className="required_label">*</sup></label>
<Select
id="head_person.identity_document.citizenship"
@ -887,7 +887,7 @@ class Form_3_Signer extends QuestionnaireForm
isSearchable={ true }
className="autocomlete"
classNamePrefix="react-select"
value={ head_person_citizenship.code !== null ? head_person_citizenship : undefined }
value={ head_person_citizenship.code !== undefined && head_person_citizenship.code !== null ? head_person_citizenship : undefined }
onChange={ (element) => { this._removeError("head_person.identity_document.citizenship"); this._handle_onCitizenshipChange(`head_person.identity_document.citizenship`, element.value) } }
required={ true }
isDisabled={ checking }
@ -1359,6 +1359,7 @@ class Form_3_Signer extends QuestionnaireForm
) }
</div>
{ parseInt(signatory_person.identity_document.doctype, 10) === 100000000 && (
<div className="form_field">
<label>Кем выдан <sup className="required_label">*</sup></label>
<DocumentIssuerSuggestsInput
@ -1373,6 +1374,7 @@ class Form_3_Signer extends QuestionnaireForm
disabled={ checking }
/>
</div>
) }
<div className="form_field">
<label>Место рождения <sup className="required_label">*</sup></label>
@ -1388,7 +1390,7 @@ class Form_3_Signer extends QuestionnaireForm
</div>
{ parseInt(signatory_person.identity_document.doctype, 10) !== 100000000 && (
<div className="form_field">
<div className="form_field" style={{ zIndex: 10 }}>
<label>Гражданство <sup className="required_label">*</sup></label>
<Select
className={ errors.indexOf("signatory_person.identity_document.placebirth") > -1 ? "autocomlete error" : "autocomlete" }
@ -1399,7 +1401,7 @@ class Form_3_Signer extends QuestionnaireForm
noOptionsMessage={ ({ inputValue }) => !inputValue ? noOptionsText :"Ничего не найдено" }
isSearchable={ true }
classNamePrefix="react-select"
value={ signatory_person_citizenship.code !== null ? signatory_person_citizenship : undefined }
value={ signatory_person_citizenship.code !== undefined && signatory_person_citizenship.code !== null ? signatory_person_citizenship : undefined }
onChange={ (element) => { this._removeError("signatory_person.identity_document.citizenship"); this._handle_onCitizenshipChange(`signatory_person.identity_document.citizenship`, element.value); } }
required={ true }
isDisabled={ checking }

View File

@ -25,6 +25,7 @@ import { checkDocumentData, saveQuestionnaire } from "../../../../actions";
import SuggestsInput from "../../SuggestsInput";
import DocumentIssuerSuggestsInput from "../../DocumentIssuerSuggestsInput";
import FormMessage from "../FormMessage";
import { traceDebug } from "../../../../utils";
class ShareholderForm extends React.Component
{
@ -284,6 +285,7 @@ class ShareholderForm extends React.Component
</div>
</div>
{ parseInt(shareholder.identity_document.doctype, 10) === 100000000 && (
<div className="form_field">
<label>Кем выдан <sup className="required_label">*</sup></label>
<DocumentIssuerSuggestsInput
@ -299,6 +301,7 @@ class ShareholderForm extends React.Component
disabled={ checking }
/>
</div>
) }
<div className="form_field">
<label>Дата рождения <sup className="required_label">*</sup></label>
@ -329,7 +332,7 @@ class ShareholderForm extends React.Component
</div>
{ parseInt(shareholder.identity_document.doctype, 10) !== 100000000 && (
<div className="form_field">
<div className="form_field" style={{ zIndex: 10 }}>
<label>Гражданство <sup className="required_label">*</sup></label>
<Select
className={ errors.indexOf("identity_document.placebirth") > -1 ? "autocomlete error" : "autocomlete" }
@ -340,7 +343,7 @@ class ShareholderForm extends React.Component
noOptionsMessage={ ({ inputValue }) => !inputValue ? noOptionsText :"Ничего не найдено" }
isSearchable={ true }
classNamePrefix="react-select"
value={ citizenship.code !== null ? citizenship : undefined }
value={ citizenship.code !== undefined && citizenship.code !== null ? citizenship : undefined }
onChange={ (element) => this._handle_onCitizenshipChange(`founder_persons[${ index }].identity_document.citizenship`, element.value) }
required={ true }
isDisabled={ checking }
@ -742,6 +745,16 @@ class Form_4_Shareholders extends QuestionnaireForm
const { founder_persons } = this.state;
this.setState({ loading: true }, async () =>
{
if(parseInt(_get("signatory_person.identity_document.doctype"), 10) === 100000000)
{
}
let total_parts = 0;
for(let f in founder_persons)
{
const check = [
"founder_part",
"lastname",
@ -755,33 +768,19 @@ class Form_4_Shareholders extends QuestionnaireForm
"identity_document.seria",
"identity_document.docnumber",
"identity_document.issuedate",
"identity_document.code",
"identity_document.issueby",
"identity_document.placebirth",
"identity_document.citizenship.code",
"identity_document.registration_address.name",
];
this.setState({ loading: true }, async () =>
{
if(parseInt(_get("signatory_person.identity_document.doctype"), 10) === 100000000)
if(parseInt(_get(founder_persons[f], "identity_document.doctype"), 10) === 100000000)
{
check.push("identity_document.code");
check.push("identity_document.issueby");
}
let total_parts = 0;
for(let f in founder_persons)
{
for(let i in check)
{
if(check[i] === "identity_document.code")
{
if(parseInt(_get(founder_persons[f], "identity_document.doctype"), 10) !== 100000000)
{
continue;
}
}
const v = _get(founder_persons[f], check[i]);
/*
Запрос 2024-02-13 на удаление телефона и адреса E-mail
@ -823,7 +822,7 @@ class Form_4_Shareholders extends QuestionnaireForm
}
else
{
if(v === "" || v === null)
if(v === "" || v === null || v === undefined)
{
errors[f].push(check[i]);
}
@ -867,6 +866,10 @@ class Form_4_Shareholders extends QuestionnaireForm
{
this.ref_submit.current.click();
}
else
{
traceDebug({ errors });
}
});
});
}

View File

@ -13,6 +13,7 @@ import QuestionnaireForm from "../QuestionnaireForm";
import { reduxWrapper } from '../../../../store';
import { saveQuestionnaire } from "../../../../actions";
import FormMessage from "../FormMessage";
import { traceDebug } from "../../../../utils";
class Form_5_Regulatory extends QuestionnaireForm
{
@ -90,6 +91,10 @@ class Form_5_Regulatory extends QuestionnaireForm
{
this.ref_submit.current.click();
}
else
{
traceDebug({ errors });
}
});
}

View File

@ -13,6 +13,7 @@ import QuestionnaireForm from "../QuestionnaireForm";
import { reduxWrapper } from '../../../../store';
import { saveQuestionnaire } from "../../../../actions";
import FormMessage from "../FormMessage";
import { traceDebug } from "../../../../utils";
class Form_6_NonProfit extends QuestionnaireForm
{
@ -169,6 +170,10 @@ class Form_6_NonProfit extends QuestionnaireForm
{
this.ref_submit.current.click();
}
else
{
traceDebug({ errors });
}
});
}

View File

@ -1358,6 +1358,10 @@
margin-top: 0;
top: 40px;
padding: 8px 12px;
z-index: 10;
}
.questionnaire .autocomlete .react-select__menu .react-select__menu-list {
z-index: 10;
}
.questionnaire .autocomlete .react-select__menu .react-select__option {
color: #8E94A7;
@ -1366,6 +1370,7 @@
background: transparent !important;
cursor: pointer;
padding: 0;
z-index: 10;
}
.questionnaire .autocomlete .react-select__menu .react-select__option:not(:last-child) {
margin-bottom: 8px;

View File

@ -1594,6 +1594,11 @@
margin-top: 0;
top: 40px;
padding: 8px 12px;
z-index: 10;
.react-select__menu-list {
z-index: 10;
}
.react-select__option {
color: #8E94A7;
@ -1602,6 +1607,7 @@
background: transparent !important;
cursor: pointer;
padding: 0;
z-index: 10;
&:not(:last-child) {
margin-bottom: 8px;

View File

@ -3,4 +3,79 @@ const _checkStrValue = (value) =>
return value !== undefined && value !== null ? value.toString() : "";
}
export { _checkStrValue }
const traceLog = (value) =>
{
if(typeof window === 'undefined')
{
if(parseInt(process.env.NEXT_PUBLIC_SERVER_LOG, 10) === 1)
{
console.log(value);
}
}
else
{
if(parseInt(process.env.NEXT_PUBLIC_LOG, 10) === 1)
{
console.log(value);
}
else
{
if(global.store?.getState()?.auth?.observer)
{
console.log(value);
}
}
}
}
const traceDebug = (value) =>
{
if(typeof window === 'undefined')
{
if(parseInt(process.env.NEXT_PUBLIC_SERVER_LOG, 10) === 1)
{
console.debug(value);
}
}
else
{
if(parseInt(process.env.NEXT_PUBLIC_LOG, 10) === 1)
{
console.debug(value);
}
else
{
if(global.store?.getState()?.auth?.observer)
{
console.debug(value);
}
}
}
}
const traceError = (value) =>
{
if(typeof window === 'undefined')
{
if(parseInt(process.env.NEXT_PUBLIC_SERVER_LOG, 10) === 1)
{
console.error(value);
}
}
else
{
if(parseInt(process.env.NEXT_PUBLIC_LOG, 10) === 1)
{
console.error(value);
}
else
{
if(global.store?.getState()?.auth?.observer)
{
console.error(value);
}
}
}
}
export { _checkStrValue, traceLog, traceDebug, traceError }