diff --git a/actions/edoActions.js b/actions/edoActions.js
index c05d1d1..33a2d74 100644
--- a/actions/edoActions.js
+++ b/actions/edoActions.js
@@ -132,4 +132,36 @@ export const inviteToEDO = () =>
reject(error.data);
});
});
+}
+
+export const createEDOProject = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/project`;
+
+ console.log("ACTION", "edo", "createEDOProject()", { url });
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "edo", "createEDOProject()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "edo", "createEDOProject()", "ERROR");
+ console.error(error);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const docEDOConnect = ({ contract_number }) =>
+{
+
}
\ No newline at end of file
diff --git a/actions/signActions.js b/actions/signActions.js
index df0fa7b..ecf097b 100644
--- a/actions/signActions.js
+++ b/actions/signActions.js
@@ -8,36 +8,30 @@ import { concatSeries, eachSeries } from 'async';
import * as actionTypes from '../constants/actionTypes';
import * as currentState from '../reducers/initialState';
-export const signCheckEDOCreatePrintForm = ({ contracts, sign_type }) =>
+export const signCheckEDOCreatePrintForm = ({ contract_number, sign_type }) =>
{
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/check`;
- console.log("ACTION", "edo", "signCheckEDOCreatePrintForm()", { url });
+ console.log("ACTION", "sign", "signCheckEDOCreatePrintForm()", { url });
return new Promise((resolve, reject) =>
{
- concatSeries(contracts, (contract_id, callback) =>
- {
- axios.post(url, { contract_number: contract_id, sign_type }, {
- withCredentials: true,
- })
- .then((response) =>
- {
- console.log("ACTION", "edo", "signCheckEDOCreatePrintForm()", "response", response.data);
-
- callback(response.data);
- })
- .catch((error) =>
- {
- console.error("ACTION", "edo", "signCheckEDOCreatePrintForm()", "ERROR");
- console.error(error);
-
- callback(error.data);
- });
- }, (error, result) =>
- {
- resolve(result);
+ axios.post(url, { contract_number, sign_type }, {
+ withCredentials: true,
})
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signCheckEDOCreatePrintForm()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signCheckEDOCreatePrintForm()", "ERROR");
+ console.error(error);
+
+ reject(error.data);
+ });
});
}
@@ -45,31 +39,97 @@ export const signGetGUIDEntity = ({ contract_number }) =>
{
const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/entity`;
- console.log("ACTION", "edo", "signGetGUIDEntity()", { url });
+ console.log("ACTION", "sign", "signGetGUIDEntity()", { url });
return new Promise((resolve, reject) =>
{
- concatSeries(contracts, (contract_id, callback) =>
- {
- axios.post(url, { contract_number: contract_id, sign_type }, {
- withCredentials: true,
- })
- .then((response) =>
- {
- console.log("ACTION", "edo", "signGetGUIDEntity()", "response", response.data);
-
- callback(response.data);
- })
- .catch((error) =>
- {
- console.error("ACTION", "edo", "signGetGUIDEntity()", "ERROR");
- console.error(error);
-
- callback(error.data);
- });
- }, (error, result) =>
- {
- resolve(result);
+ axios.post(url, { contract_number }, {
+ withCredentials: true,
})
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signGetGUIDEntity()", "response", response.data);
+
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signGetGUIDEntity()", "ERROR");
+ console.error(error);
+
+ resolve(response.data);
+ });
+ });
+}
+
+export const signCheckPowerAttorneyClient = ({ contract_number }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/check`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, { contract_number }, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signCheckPowerAttorneyClient()", "response", response.data);
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signCheckPowerAttorneyClient()", "ERROR");
+ console.error(error);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signGetPowerAttorneyClient = ({ contract_number }) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/attorney/get`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, { contract_number }, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signGetPowerAttorneyClient()", "response", response.data);
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signGetPowerAttorneyClient()", "ERROR");
+ console.error(error);
+
+ reject(error.data);
+ });
+ });
+}
+
+export const signGetWMDoc = (payload) =>
+{
+ const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/document`;
+
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(url, payload, {
+ withCredentials: true,
+ })
+ .then((response) =>
+ {
+ console.log("ACTION", "sign", "signGetWMDoc()", "response", response.data);
+ resolve(response.data);
+ })
+ .catch((error) =>
+ {
+ console.error("ACTION", "sign", "signGetWMDoc()", "ERROR");
+ console.error(error);
+
+ reject(error.data);
+ });
});
}
\ No newline at end of file
diff --git a/components/DealsStatus/SingleDeal.js b/components/DealsStatus/SingleDeal.js
index 4aef9b1..c67bfd9 100644
--- a/components/DealsStatus/SingleDeal.js
+++ b/components/DealsStatus/SingleDeal.js
@@ -731,6 +731,38 @@ class LeasingRegistration extends Step
key: "annulled_contracts",
},
];
+ this.container_ref = React.createRef();
+ }
+
+ _handle_onScrollToContainer = () =>
+ {
+ const element = this.container_ref.current;
+ const y = (element.getBoundingClientRect().top + window.scrollY - 160);
+ window.scrollTo({top: y, behavior: 'smooth'});
+ }
+
+ _handle_onPreparedContract = (contract) =>
+ {
+ const checked = [ ...this.state.checked ];
+
+ if(checked.indexOf(contract) > -1)
+ {
+ checked.splice(checked.indexOf(contract), 1);
+ }
+ else
+ {
+ checked.push(contract);
+ }
+
+ this.setState({ checked });
+ }
+
+ _handle_onSignEDO = () =>
+ {
+ this.setState({ edo: true }, () =>
+ {
+ this._handle_onScrollToContainer();
+ });
}
_getEDODocuments = () =>
@@ -756,22 +788,6 @@ class LeasingRegistration extends Step
return documents;
}
- _handle_onPreparedContract = (contract) =>
- {
- const checked = [ ...this.state.checked ];
-
- if(checked.indexOf(contract) > -1)
- {
- checked.splice(checked.indexOf(contract), 1);
- }
- else
- {
- checked.push(contract);
- }
-
- this.setState({ checked });
- }
-
_render_preparedContracts = () =>
{
const { edo, checked } = this.state;
@@ -813,7 +829,7 @@ class LeasingRegistration extends Step
{ contracts.length > 0 &&
(
-
+
) }
@@ -1001,7 +1017,7 @@ class LeasingRegistration extends Step
const { open, edo } = this.state;
return (
- -1 ? "current" : statuscode_id > this.status[ 0 ] ? "done" : "" }`}>
+
-1 ? "current" : statuscode_id > this.status[ 0 ] ? "done" : "" }`} ref={ this.container_ref }>
№ { dealSelected }
@@ -1043,6 +1059,7 @@ export default class SingleDeal extends React.Component
constructor(props)
{
super(props);
+ this.leasing_registration_ref = React.createRef();
}
render()
diff --git a/components/EDOSign/index.js b/components/EDOSign/index.js
index 04503de..86b0c8f 100644
--- a/components/EDOSign/index.js
+++ b/components/EDOSign/index.js
@@ -2,8 +2,12 @@ import React from "react";
import { connect } from "react-redux";
import moment from "moment";
import { SpinnerCircular } from "spinners-react";
+import { concatSeries } from "async";
+import { eachSeries } from 'async';
+import Select from 'react-select';
-import { signCheckEDOCreatePrintForm } from "../../actions";
+
+import { createEDOProject, signCheckEDOCreatePrintForm, signCheckPowerAttorneyClient, signGetGUIDEntity, signGetPowerAttorneyClient, signGetWMDoc } from "../../actions";
//import { getDeals, getDealOffers, getDealDocuments, getDealContracts } from "../../actions";
class EDOSign extends React.Component
@@ -14,7 +18,9 @@ class EDOSign extends React.Component
this.state = {
operators: null,
loading: false,
- selected: {},
+ documents: [],
+ operator_selected: {},
+ statuses: {},
}
}
@@ -28,49 +34,215 @@ class EDOSign extends React.Component
componentDidMount()
{
- if(this.state.selected.box_id === undefined)
+ const docs = [];
+ for(let i in this.props.documents)
{
- this.setState({ selected: this.state.operators !== null && this.state.operators[0] !== undefined ? this.state.operators[0] : {} });
+ docs.push({ ...this.props.documents[i], ...{ index: i, loading: true, completed: false, attorney: false } });
}
+ this.setState({ documents: docs });
+
+ if(this.state.operator_selected.box_id === undefined)
+ {
+ this.setState({ operator_selected: this.state.operators !== null && this.state.operators[0] !== undefined ? this.state.operators[0] : {} });
+ }
+ }
+
+ _updateDocs = (id, update) =>
+ {
+ return new Promise((resolve) =>
+ {
+ const docs = [ ...this.state.documents ];
+ docs[ id ] = { ...docs[id], ...update };
+
+ this.setState({ documents: docs }, () =>
+ {
+ resolve();
+ });
+ });
}
_handle_onFormSubmit = (event) =>
{
event.preventDefault();
- const { documents } = this.props;
- const { selected } = this.state;
+ //const { documents } = this.props;
+ const { operator_selected } = this.state;
+ const documents = [ ...this.state.documents ];
+
console.log("_handle_onFormSubmit");
- console.log({ documents, selected });
+ console.log({ documents, operator_selected });
this.setState({ loading: true }, () =>
{
- const contracts = [];
- for(let i in documents)
+ eachSeries(documents, async (document, callback) =>
{
- contracts.push(documents[i].id);
- signCheckEDOCreatePrintForm({ contracts, sign_type: "EDO" })
- .then((checks) =>
+ if(document.completed)
{
- console.log({ checks });
- })
- .catch((error) =>
+ callback();
+ }
+ else
{
- console.log({ error });
- });
- }
+ console.log({ document })
+ await this._updateDocs(document.index, { loading: true });
+
+ if(document.attorney && document.attorney_selected !== undefined)
+ {
+ const create_edo_project_result = await createEDOProject({
+ contract_number: document.id,
+ power_attorney: document.attorney_selected.value,
+ power_attorney_number: document.attorney_selected.label,
+ edo_box: operator_selected.edo_box,
+ });
+
+ console.log("\n\nIMPORTANT !!!!!!!!!!\n\n");
+ console.log({ create_edo_project_result });
+
+ const get_guid_entity_result = await signGetGUIDEntity({
+ contract_number: document.id,
+ });
+
+ console.log("\n\nENTITY !!!!!!!!!!\n\n");
+ console.log({ get_guid_entity_result });
+
+ await this._updateDocs(document.index, {
+ entity_id: get_guid_entity_result.entityid,
+ completed: true,
+ loading: false,
+ attorney: false,
+ });
+
+ callback();
+ }
+ else
+ {
+ const create_print_form_result = await signCheckEDOCreatePrintForm({ contract_number: document.id === "2023_5885" ? "2023_5894" : document.id, sign_type: "EDO" });
+ console.log({ create_print_form_result });
+
+ const docs = { status: create_print_form_result.status };
+
+ if(create_print_form_result.status !== "success")
+ {
+ docs.loading = false;
+ docs.error = true;
+ docs.completed = true;
+ docs.message = create_print_form_result.message;
+ }
+
+ await this._updateDocs(document.index, docs);
+
+ if(create_print_form_result.status === "success")
+ {
+ const check_attorney_client_result = await signCheckPowerAttorneyClient({ contract_number: document.id })
+ console.log({ check_attorney_client_result });
+
+ await this._updateDocs(document.index, { attorney: check_attorney_client_result.power_attorney_required, });
+
+ if(check_attorney_client_result.power_attorney_required)
+ {
+ const get_attorney_client_result = await signGetPowerAttorneyClient({ contract_number: document.id });
+ console.log({ get_attorney_client_result });
+
+ if(get_attorney_client_result === null)
+ {
+ await this._updateDocs(document.index, { loading: false, error: true, completed: true, message: "Возникла ошибка при создании документа для подписания." });
+ callback();
+ }
+ else
+ {
+ if(get_attorney_client_result.length === null)
+ {
+ await this._updateDocs(document.index, { loading: false, error: true, completed: true, message: "Не обнаружена доверенность на подписанта. Для продолжения подписания обратитесь к своему персональному менеджеру" });
+ callback();
+ }
+ else
+ {
+ const attorneys = [];
+ for(let i in get_attorney_client_result)
+ {
+ attorneys.push({
+ value: get_attorney_client_result[i].power_attorney,
+ label: get_attorney_client_result[i].power_attorney_number,
+ });
+ }
+
+ await this._updateDocs(document.index, { loading: false, error: false, attorneys, attorney_selected: undefined });
+
+ callback();
+ }
+ }
+ }
+ else
+ {
+ const create_edo_project_result = await createEDOProject({
+ contract_number: document.id,
+ edo_box: operator_selected.edo_box,
+ });
+
+ const get_guid_entity_result = await signGetGUIDEntity({
+ contract_number: document.id,
+ });
+
+ await this._updateDocs(document.index, {
+ entity_id: get_guid_entity_result.entityid,
+ completed: true,
+ loading: false,
+ attorney: false,
+ });
+
+ callback();
+ }
+ }
+ else
+ {
+ callback();
+ }
+ }
+ }
+ }, () =>
+ {
+ this.setState({ loading: false });
+ });
})
}
_handle_onSelectOperator = (operator) =>
{
- this.setState({ selected: operator });
+ this.setState({ operator_selected: operator });
+ }
+
+ _handle_onAttorneyChange = (index, attorney) =>
+ {
+ console.log("_handle_onAttorneyChange", { index, attorney });
+ this._updateDocs(index, { attorney_selected: attorney });
+ }
+
+ _handle_onDownloadFile = (index, entity_id) =>
+ {
+ console.log("_handle_onDownloadFile", { index, entity_id })
+ this.setState({ loading: true }, async () =>
+ {
+ await this._updateDocs(index, { loading: true });
+
+ const wmdoc_result = await signGetWMDoc({ entity_name: "evo_contract", entity_id, sign_type: "EDO" });
+ console.log({ wmdoc_result });
+
+ await this._updateDocs(index, { loading: false });
+ });
+ }
+
+ _handle_onCancelFile = async (index, entity_id) =>
+ {
+ await this._updateDocs(index, { loading: true });
+ this.setState({ loading: true }, async () =>
+ {
+ await this._updateDocs(index, { loading: true });
+ });
}
render()
{
- const { operators, loading, selected } = this.state;
- const { onCancel, documents } = this.props;
+ const { operators, documents, loading, operator_selected } = this.state;
+ const { onCancel, } = this.props;
console.log({ operators, documents });
return (
@@ -78,13 +250,69 @@ class EDOSign extends React.Component
-
+
{ documents.map((document, index) =>
(
-
- { document.name } от { moment(document.date).format("DD.MM.YYYY") }
- { document.type !== undefined && ({ document.type }) }
-
+
+
+
+ { document.name } от { moment(document.date).format("DD.MM.YYYY") }
+ { document.type !== undefined && ({ document.type }) }
+
+
+
+ { document.loading ? (
+ <>
+ { loading && (
+
+ ) }
+ >
+ ) : (
+ <>
+ { document.error ? (
+ <>
+
+
{ document.message }
+ >
+ ) : (
+ <>
+ { document.attorney && (
+ <>
+
+
+
+ >
+ ) }
+ { document.completed && (
+ <>
+
+ { document.entity_id !== undefined && (
+ <>
+
+
+ >
+ ) }
+ >
+ ) }
+ >
+ ) }
+ >
+ ) }
+
+
)) }