diff --git a/actions/questionnaireActions.js b/actions/questionnaireActions.js
index 5447a21..84776e3 100644
--- a/actions/questionnaireActions.js
+++ b/actions/questionnaireActions.js
@@ -7,6 +7,7 @@ import fileDownload from 'js-file-download';
import { eachSeries, each } from "async";
import * as actionTypes from '../constants/actionTypes';
+import { getCitizenshipTitleByCode } from '../utils/citizenship';
if(process.browser)
{
@@ -24,36 +25,60 @@ if(process.browser)
};
}
-export const getQuestionnaire = ({ dispatch }) =>
+export const getQuestionnaire = ({ dispatch, id }) =>
{
console.log("ACTION", "support", "getAppeals()", `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/get`);
return new Promise((resolve, reject) =>
{
- axios.get(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/get`)
+ axios.get(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/get`, {
+ params: {
+ id
+ }
+ })
.then((response) =>
{
console.log("ACTION", "questionnaire", "getQuestionnaire()", "response", response.data);
const questionnaire = JSON.parse(JSON.stringify(global.store.getState().questionnaire));
- questionnaire.main.title = response.data.title;
- questionnaire.main.inn = response.data.inn;
- questionnaire.main.kpp = response.data.kpp;
- questionnaire.main.telephone = response.data.telephone;
- questionnaire.main.email = response.data.email;
- questionnaire.main.websiteurl = response.data.websiteurl !== null ? response.data.websiteurl : "";
- questionnaire.main.financial_loan = response.data.financial_loan !== null ? response.data.financial_loan : "";
+ if(questionnaire.status === "empty")
+ {
+ questionnaire.main.title = response.data.title;
+ questionnaire.main.inn = response.data.inn;
+ questionnaire.main.kpp = response.data.kpp;
+ questionnaire.main.telephone = response.data.telephone;
+ questionnaire.main.email = response.data.email;
+ questionnaire.main.websiteurl = response.data.websiteurl !== null ? response.data.websiteurl : "";
+ questionnaire.main.financial_loan = response.data.financial_loan !== null ? response.data.financial_loan : "";
- questionnaire.contacts.fact_address = response.data.fact_address;
- questionnaire.contacts.postal_address = response.data.postal_address;
- questionnaire.contacts.legal_address = response.data.legal_address;
+ questionnaire.contacts.address_type = response.data.inn.length > 10 ? "fact" : "legal";
+ questionnaire.contacts.fact_address = response.data.fact_address;
+ questionnaire.contacts.postal_address = response.data.postal_address;
+ questionnaire.contacts.legal_address = response.data.legal_address;
- console.log("questionnairequestionnairequestionnaire FROM JSON", questionnaire);
- updateQuestionnaire({ dispatch, questionnaire })
- .then(() => {})
- .catch(() => {});
- //dispatch({ type: actionTypes.SUPPORT_APPEALS, data: { appeals: { list: response.data.appeals, new: response.data.new, } } });
- resolve();
+ questionnaire.head_person = { ...questionnaire.head_person, ...response.data.head_person };
+ questionnaire.head_person.identity_document.citizenship = {
+ title: getCitizenshipTitleByCode(response.data.head_person.identity_document.citizenship_code),
+ code: response.data.head_person.identity_document.citizenship_code,
+ };
+
+ questionnaire.signatory_person = { ...questionnaire.signatory_person, ...response.data.signatory_person };
+ questionnaire.signatory_person.identity_document.citizenship = {
+ title: getCitizenshipTitleByCode(response.data.signatory_person.identity_document.citizenship_code),
+ code: response.data.signatory_person.identity_document.citizenship_code,
+ };
+
+ console.log("questionnairequestionnairequestionnaire FROM JSON", questionnaire);
+ updateQuestionnaire({ dispatch, questionnaire })
+ .then(() => {})
+ .catch(() => {});
+ //dispatch({ type: actionTypes.SUPPORT_APPEALS, data: { appeals: { list: response.data.appeals, new: response.data.new, } } });
+ resolve();
+ }
+ else
+ {
+ resolve();
+ }
})
.catch((error) =>
{
@@ -93,7 +118,7 @@ export const uploadAttachmentFile = (file) =>
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/file/upload`, data,
{
headers: {
- "Content-Type": "multipart/form-data",
+ "Content-Type": "multipart/form-data; charset=utf-8",
},
withCredentials: true,
})
@@ -110,6 +135,32 @@ export const uploadAttachmentFile = (file) =>
});
}
+export const removeAttachmentFile = (id) =>
+{
+ console.log("ACTION", "questionnaireActions", "removeAttachmentFile()", { id });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.delete(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/file/remove`,
+ {
+ params: {
+ id
+ },
+ withCredentials: true,
+ })
+ .then(async (response) =>
+ {
+ console.log("questionnaireActions", "removeAttachmentFile()", "complete");
+ resolve();
+ })
+ .catch((error) =>
+ {
+ console.error(error);
+ reject();
+ });
+ });
+}
+
export const downloadQuestionnaire = (download = true) =>
{
console.log("ACTION", "questionnaireActions", "downloadQuestionnaire()", );
diff --git a/actions/suggestsActions.js b/actions/suggestsActions.js
index ab5a0cb..bb1fe8c 100644
--- a/actions/suggestsActions.js
+++ b/actions/suggestsActions.js
@@ -36,6 +36,48 @@ export const getAddress = (query) =>
console.log("error");
console.error(error);
+ reject();
+ });
+ });
+}
+
+export const getFullnamePart = (query, parts) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/suggests/name`, { query, parts }, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.log("error");
+ console.error(error);
+
+ reject();
+ });
+ });
+}
+
+export const getSuggests = (type, payload) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/suggests/${ type }`, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.log("error");
+ console.error(error);
+
reject();
});
});
diff --git a/components/questionnaire/AddressSuggests.js b/components/questionnaire/AddressSuggests.js
index 7083a7f..729d700 100644
--- a/components/questionnaire/AddressSuggests.js
+++ b/components/questionnaire/AddressSuggests.js
@@ -11,11 +11,11 @@ import AsyncSelect from 'react-select/async';
import debounce from 'debounce-promise';
import { set as _set, get as _get } from 'lodash';
-import { getAddress } from '../../actions';
+import { getAddress, getSuggests } from '../../actions';
-const suggestsAddressDebounce = (text) =>
+const suggestsAddressDebounce = (query) =>
{
- return getAddress(text);
+ return getSuggests("address", { query });
}
const suggestsAddress = debounce(suggestsAddressDebounce, 200);
@@ -118,55 +118,35 @@ export default class AddressSuggests extends React.Component
render()
{
const { focused, options } = this.state;
- const { value, disabled, required } = this.props;
+ const { value, disabled, required, placeholder } = this.props;
return (
-
-
this._handle_onChange(event.target.value) }
- onFocus={ this._handle_onFocus }
- onBlur={ this._handle_onBlur }
- required={ required }
- disabled={ disabled }
- />
- { focused && options.length > 0 && (
-
-
- { options.map((option, index) =>
- (
-
this._handle_onSelect(option.value) }>{ option.value }
- )) }
-
+
+
this._handle_onChange(event.target.value) }
+ onFocus={ this._handle_onFocus }
+ onBlur={ this._handle_onBlur }
+ required={ required }
+ disabled={ disabled }
+ />
+ { focused && options.length > 0 && (
+
+
+ { options.map((option, index) =>
+ (
+
this._handle_onSelect(option.value) }>{ option.value }
+ )) }
- ) }
-
- );
-
-
- /*
-
null }
- loadingMessage={ () => null }
- loadOptions={ (text) => this._getAddress(text) }
- onChange={ this._handle_onChange }
- //onBlur={ this._handle_onBlur }
- onInputChange={ this._handle_onInputChange }
- //isDisabled={ disabled ? true : false }
- />
- */
+
+ ) }
+
+ );
}
}
\ No newline at end of file
diff --git a/components/questionnaire/SuggestsInput.js b/components/questionnaire/SuggestsInput.js
new file mode 100644
index 0000000..df83ab9
--- /dev/null
+++ b/components/questionnaire/SuggestsInput.js
@@ -0,0 +1,189 @@
+import React from "react";
+import Head from 'next/head';
+import Image from 'next/image';
+import Link from "next/link";
+import cookie from 'cookie';
+import { connect } from "react-redux";
+import numeral from "numeral";
+import pluralize from 'pluralize-ru';
+import { SpinnerCircular } from 'spinners-react';
+import AsyncSelect from 'react-select/async';
+import debounce from 'debounce-promise';
+import { set as _set, get as _get } from 'lodash';
+
+import { getSuggests } from '../../actions';
+
+const suggestsAddressDebounce = (query) =>
+{
+ return getSuggests("address", { query });
+}
+
+const suggestsFirstnameDebounce = (query) =>
+{
+ return getSuggests("name", { query, parts: ["NAME"] });
+}
+
+const suggestsMiddlenameDebounce = (query) =>
+{
+ return getSuggests("name", { query, parts: ["PATRONYMIC"] });
+}
+
+const suggestsLastnameDebounce = (query) =>
+{
+ return getSuggests("name", { query, parts: ["SURNAME"] });
+}
+
+const suggestsAddress = debounce(suggestsAddressDebounce, 200);
+const suggestsFirstname = debounce(suggestsFirstnameDebounce, 200);
+const suggestsMiddlename = debounce(suggestsMiddlenameDebounce, 200);
+const suggestsLastname = debounce(suggestsLastnameDebounce, 200);
+
+export default class SuggestsInput extends React.Component
+{
+ constructor(props)
+ {
+ super(props);
+ this.state = {
+ focused: false,
+ options: [],
+ };
+ }
+
+ componentDidMount()
+ {
+ }
+
+ componentDidUpdate(prevProps, prevState)
+ {
+ }
+
+ _handle_onChange = (value) =>
+ {
+ const { focused } = this.state;
+ const { onChange } = this.props;
+
+ onChange(value);
+ if(focused)
+ {
+ this._getValue(value);
+ }
+ }
+
+ _handle_onSelect = (value) =>
+ {
+ const { onChange } = this.props;
+
+ this.setState({ focused: false }, () =>
+ {
+ onChange(value);
+ });
+ }
+
+ _handle_onFocus = () =>
+ {
+ this.setState({ focused: true });
+ }
+
+ _handle_onBlur = () =>
+ {
+ setTimeout(() =>
+ {
+ this.setState({ focused: false });
+ }, 100);
+ }
+
+ _getSuggests = (text) =>
+ {
+ const { type } = this.props;
+
+ return new Promise((resolve, reject) =>
+ {
+ if(type === "lastname")
+ {
+ suggestsLastname(text).then((result) => { resolve(result); }).catch(() => {});
+ }
+
+ if(type === "firstname")
+ {
+ suggestsFirstname(text).then((result) => { resolve(result); }).catch(() => {});
+ }
+
+ if(type === "middlename")
+ {
+ suggestsMiddlename(text).then((result) => { resolve(result); }).catch(() => {});
+ }
+ });
+ }
+
+ _getValue = (text) =>
+ {
+ return new Promise((resolve, reject) =>
+ {
+ if(text === "")
+ {
+ this.setState({ options: [], value: "" }, () =>
+ {
+ resolve([]);
+ });
+ }
+ else
+ {
+ this._getSuggests(text)
+ .then((result) =>
+ {
+ const options = [];
+
+ for(let i in result.suggestions)
+ {
+ const s = result.suggestions[i];
+ options.push({ value: s.value, label: s.value });
+ }
+
+ this.setState({ options }, () =>
+ {
+ resolve(options);
+ });
+ })
+ .catch(() =>
+ {
+
+ });
+ }
+ })
+ }
+
+ render()
+ {
+ const { focused, options } = this.state;
+ const { value, disabled, required, placeholder, name } = this.props;
+
+ return (
+
+
this._handle_onChange(event.target.value) }
+ onFocus={ this._handle_onFocus }
+ onBlur={ this._handle_onBlur }
+ required={ required }
+ disabled={ disabled }
+ />
+ { focused && options.length > 0 && (
+
+
+ { options.map((option, index) =>
+ (
+
this._handle_onSelect(option.value) }>{ option.value }
+ )) }
+
+
+ ) }
+
+ );
+ }
+}
\ No newline at end of file
diff --git a/components/questionnaire/forms/AddressSuggestsSelect.js b/components/questionnaire/forms/AddressSuggestsSelect.js
index 0f320dc..4d1dd8c 100644
--- a/components/questionnaire/forms/AddressSuggestsSelect.js
+++ b/components/questionnaire/forms/AddressSuggestsSelect.js
@@ -7,14 +7,14 @@ import { connect } from "react-redux";
import numeral from "numeral";
import pluralize from 'pluralize-ru';
import { SpinnerCircular } from 'spinners-react';
-import { getAddress } from '../../../actions';
+import { getSuggests } from '../../../actions';
import debounce from 'debounce-promise';
import { set as _set, get as _get } from 'lodash';
import AsyncSelect from 'react-select/async';
-const suggestsAddressDebounce = (text) =>
+const suggestsAddressDebounce = (query) =>
{
- return getAddress(text);
+ return getSuggests("address", { query });
}
const suggestsAddress = debounce(suggestsAddressDebounce, 200);
@@ -222,31 +222,5 @@ export default class AddressSuggestsSelect extends React.Component
/>
)
}
- /*
- if(value_selected !== "")
- {
- console.log("22222222222222222");
- return (
-
null }
- loadingMessage={ () => null }
- loadOptions={ (text) => this._getAddress(text) }
- onChange={ this._handle_onChange }
- //onBlur={ this._handle_onBlur }
- onInputChange={ this._handle_onInputChange }
- />
- )
- }
- else
- {
- */
-
- //}
}
}
\ No newline at end of file
diff --git a/components/questionnaire/forms/FilesList.js b/components/questionnaire/forms/FilesList.js
index 3faaba4..c3de22e 100644
--- a/components/questionnaire/forms/FilesList.js
+++ b/components/questionnaire/forms/FilesList.js
@@ -10,7 +10,7 @@ import { SpinnerCircular } from 'spinners-react';
import Dropzone from 'react-dropzone';
import { each, concat, concatSeries } from 'async';
-import { uploadAttachmentFile } from "../../../actions";
+import { uploadAttachmentFile, removeAttachmentFile } from "../../../actions";
export default class FilesList extends React.Component
{
@@ -51,10 +51,20 @@ export default class FilesList extends React.Component
});
}
- _handle_onRemoveFile = (file_name) =>
+ _handle_onRemoveFile = (file) =>
{
+ console.log("_handle_onRemoveFile", { file: file });
const { name, onRemoveFile } = this.props;
- onRemoveFile(name, file_name);
+
+ removeAttachmentFile(file.id)
+ .then(() =>
+ {
+ onRemoveFile(name, file.id);
+ })
+ .catch(() =>
+ {
+
+ });
}
_renderFileName = (name) =>
@@ -100,7 +110,7 @@ export default class FilesList extends React.Component
{ this._renderFileName(file.name) }{/*}Постановление{*/}
{ !checking && (
- this._handle_onRemoveFile(file.name) }>
+
this._handle_onRemoveFile(file) }>
✕
) }
@@ -121,7 +131,7 @@ export default class FilesList extends React.Component
{ !checking && (
this._handle_onAddFile(acceptedFiles) }>
{ ({getRootProps, getInputProps}) => (
-
+
) }
diff --git a/components/questionnaire/forms/Form_1_Main/index.js b/components/questionnaire/forms/Form_1_Main/index.js
index 3f67a3d..42da1da 100644
--- a/components/questionnaire/forms/Form_1_Main/index.js
+++ b/components/questionnaire/forms/Form_1_Main/index.js
@@ -244,33 +244,35 @@ class Form_1_Main extends QuestionnaireForm
сумма текущих ежемесячных платежей по действующим кредитам/договорам лизинга
-
-
-
-
- this._handle_onNonProfitChange() }
- disabled={ main.nko && checking }
- />
-
-
-
-
this._handle_onNonProfitChange() }
- disabled={ !main.nko && checking }
- />
-
+ { company.inn.length < 11 && (
+
+
+
-
+ ) }
{ !checking && (
diff --git a/components/questionnaire/forms/Form_2_Contacts/index.js b/components/questionnaire/forms/Form_2_Contacts/index.js
index 99fbdad..1f0f7a7 100644
--- a/components/questionnaire/forms/Form_2_Contacts/index.js
+++ b/components/questionnaire/forms/Form_2_Contacts/index.js
@@ -25,20 +25,20 @@ class Form_2_Contacts extends QuestionnaireForm
loading: false,
fact_address: {
- title: "",
+ name: "",
fias_id: "",
},
legal_address: {
- title: "",
+ name: "",
fias_id: "",
},
postal_address: {
- title: "",
+ name: "",
fias_id: "",
},
},
value: {
- title: "",
+ name: "",
fias_id: "",
}
};
@@ -53,6 +53,15 @@ class Form_2_Contacts extends QuestionnaireForm
componentDidMount()
{
+ const { company } = this.props;
+ const { address_type } = this.state.contacts;
+
+ console.log("company.inncompany.inncompany.inncompany.inn", company.inn, address_type);
+ if(company.inn.length > 10 && address_type === "legal")
+ {
+ console.log("THIS ?");
+ this.setState({ address_type: "fact" });
+ }
}
_handle_onFormSubmit = (event) =>
@@ -74,7 +83,7 @@ class Form_2_Contacts extends QuestionnaireForm
if(contacts.address_type === "fact")
{
- if(contacts.fact_address.title === "")
+ if(contacts.fact_address.name === "")
{
return true;
}
@@ -82,7 +91,7 @@ class Form_2_Contacts extends QuestionnaireForm
if(contacts.address_type === "postal")
{
- if(contacts.postal_address.title === "")
+ if(contacts.postal_address.name === "")
{
return true;
}
@@ -105,7 +114,7 @@ class Form_2_Contacts extends QuestionnaireForm
this._handle_onTextFieldChange("contacts.fact_address", data) }
required={ address_type === "fact" ? true : false }
@@ -157,7 +166,7 @@ class Form_2_Contacts extends QuestionnaireForm