diff --git a/actions/questionnaireActions.js b/actions/questionnaireActions.js
index 4c222d5..fa22821 100644
--- a/actions/questionnaireActions.js
+++ b/actions/questionnaireActions.js
@@ -9,6 +9,7 @@ import { eachSeries, each } from "async";
import * as actionTypes from '../constants/actionTypes';
import { getCitizenshipTitleByCode } from '../utils/citizenship';
import { questionnaire_template } from '../reducers/initialState';
+import { getCompanyInfo } from './companyActions';
if(process.browser)
{
@@ -26,11 +27,28 @@ if(process.browser)
};
}
+export const createQuestionnaire = (deal_id) =>
+{
+ return new Promise((resolve, reject) =>
+ {
+ axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/questionnaire/create`, { deal_id }, {
+ withCredentials: true,
+ })
+ .then(() => {}).catch(() => {}).finally(() =>
+ {
+ getCompanyInfo({ dispatch: global.store.dispatch })
+ .then(() => {}).catch(() => {}).finally(() =>
+ {
+ resolve();
+ });
+ });
+ });
+}
+
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/read`, {})
diff --git a/components/DealsStatus/components/DocumentsForm.js b/components/DealsStatus/components/DocumentsForm.js
index f2f17de..5bbd812 100644
--- a/components/DealsStatus/components/DocumentsForm.js
+++ b/components/DealsStatus/components/DocumentsForm.js
@@ -4,11 +4,96 @@ import { SpinnerCircular } from "spinners-react";
import FileDropzoneDeals from "../../FileDropzoneDeals";
-import { attachDealDocument, removeDealDocument, sendDealDocuments, } from "../../../actions";
+import { attachDealDocument, createQuestionnaire, removeDealDocument, sendDealDocuments, } from "../../../actions";
import Step from "./Step";
import md5 from "md5";
+class QuestionnaireForm extends React.Component
+{
+ constructor(props)
+ {
+ super(props);
+ this.state = {
+ loading: false
+ }
+ }
+
+ _handle_onQuestionnaire = (event) =>
+ {
+ event.preventDefault();
+ const { onQuestionnaire } = this.props;
+
+ onQuestionnaire();
+ }
+
+ _handle_onCreateQuestionnaire = (event) =>
+ {
+ event.preventDefault();
+ const { onQuestionnaire, deal_id } = this.props;
+
+ this.setState({ loading: true, }, () =>
+ {
+ createQuestionnaire(deal_id)
+ .then(() =>
+ {
+ onQuestionnaire();
+ });
+ });
+ }
+
+ render()
+ {
+ const { loading } = this.state;
+ const { questionnaire_status } = this.props;
+
+ switch(questionnaire_status)
+ {
+ case "need_to_fill":
+ {
+ return (
+
+
Требуется обновить данные в анкете
+
+
+ )
+ }
+
+ case "need_to_create":
+ {
+ return (
+
+
Требуется предоставить данные в анкете клиента
+
+
+ )
+ }
+
+ case "up_to_date":
+ {
+
+
Вам не требуется актуализация данных анкеты Клиента
+
+ }
+
+ default:
+ {
+ return (
+
+
Проводится проверка анкеты Вашей организации
+
+ )
+ }
+ }
+ }
+}
+
export default class DocumentsForm extends Step
{
constructor(props)
@@ -20,6 +105,7 @@ export default class DocumentsForm extends Step
uploading: false,
completed: false,
loading: true,
+ questionnaire_loading: false,
};
this.status = 102;
}
@@ -176,44 +262,39 @@ export default class DocumentsForm extends Step
});
}
- _handle_onQuestionnaire = (event) =>
- {
- const { onQuestionnaire } = this.props;
-
- event.preventDefault();
- onQuestionnaire();
- }
-
_checkFilesCompleted = () =>
{
const { uploaded } = this.state;
- const { documents } = this.props;
+ const { documents, questionnaire_status, } = this.props;
let c = true;
- if(documents !== undefined)
+ if(questionnaire_status !== "need_to_fill" && questionnaire_status !== "need_to_create")
{
- for(let g in documents)
+ if(documents !== undefined)
{
- if(!documents[g].add)
+ for(let g in documents)
{
- continue;
- }
-
- const group = md5(`${ documents[g].doc_id }_${ documents[g].name }`);
-
- if(uploaded[group] === undefined || uploaded[group].files.length === 0)
- {
- c = false;
- break;
- }
- else
- {
- for(let f in uploaded[group].files)
+ if(!documents[g].add)
{
- if(!uploaded[group].files[f].uploaded)
+ continue;
+ }
+
+ const group = md5(`${ documents[g].doc_id }_${ documents[g].name }`);
+
+ if(uploaded[group] === undefined || uploaded[group].files.length === 0)
+ {
+ c = false;
+ break;
+ }
+ else
+ {
+ for(let f in uploaded[group].files)
{
- c = false;
- break;
+ if(!uploaded[group].files[f].uploaded)
+ {
+ c = false;
+ break;
+ }
}
}
}
@@ -229,7 +310,7 @@ export default class DocumentsForm extends Step
render()
{
- const { index, statuscode_id, dealSelected, documents, questionnaire_status, } = this.props;
+ const { index, statuscode_id, dealSelected, documents, questionnaire_status, onQuestionnaire, } = this.props;
const { open, uploaded, uploading, loading, completed } = this.state;
return (
@@ -250,24 +331,11 @@ export default class DocumentsForm extends Step
Анкета клиента:
- { questionnaire_status === "need_to_fill" ? (
-
-
Требуется обновить данные в анкете
-
-
- ) : (
- <>
- { questionnaire_status !== "up_to_date" ? (
-
-
Проводится проверка анкеты Вашей организации
-
- ) : (
-
-
Вам не требуется актуализация данных анкеты Клиента
-
- ) }
- >
- ) }
+
{ documents === undefined ? (
diff --git a/pages/api/company.js b/pages/api/company.js
index 2c20572..e5550bc 100644
--- a/pages/api/company.js
+++ b/pages/api/company.js
@@ -34,6 +34,7 @@ export default async function handler(req, res)
})
.then((crm_response) =>
{
+ console.log("/Account/GetCompanyInfo/", "RESPONSE", { data: crm_response.data });
res.status(200).json({ ...crm_response.data, ...{ active: client_jwt_decoded.acc_number } });
})
.catch((error) =>
diff --git a/pages/api/questionnaire/create.js b/pages/api/questionnaire/create.js
new file mode 100644
index 0000000..1c89d3b
--- /dev/null
+++ b/pages/api/questionnaire/create.js
@@ -0,0 +1,20 @@
+import CRMRequestPost from '../../../lib/CRMRequestPost';
+
+export default async function handler(req, res)
+{
+ console.log("\n\n", "API", "/questionnaire/create");
+ const { deal_id } = req.body;
+
+ const payload = {
+ opp_number: deal_id,
+ };
+
+ console.log({ payload });
+
+ await CRMRequestPost({ req, res,
+ path: `${ process.env.CRM_API_HOST }/lk/Questionnaire/Create`,
+ params: payload,
+ headers: { "Content-Type": "application/json" },
+ log: true,
+ });
+}
\ No newline at end of file