diff --git a/actions/companyActions.js b/actions/companyActions.js index c0299df..24d986f 100644 --- a/actions/companyActions.js +++ b/actions/companyActions.js @@ -4,7 +4,7 @@ import Router from 'next/router'; import moment from 'moment'; import * as actionTypes from '../constants/actionTypes'; -import { getEDOList } from './edoActions'; +import { getEDOOperatorList } from './index'; if(process.browser) { @@ -33,7 +33,7 @@ export const getCompanyInfo = ({ dispatch }) => }) .then((response) => { - getEDOList({ dispatch }).then(() => {}).catch(() => {}); + getEDOOperatorList({ dispatch }).then(() => {}).catch(() => {}); //console.log("getCompanyInfo", "response", response.data); dispatch({ type: actionTypes.COMPANY, data: response.data }); diff --git a/actions/edoActions.js b/actions/edoActions.js index 12aaf90..c05d1d1 100644 --- a/actions/edoActions.js +++ b/actions/edoActions.js @@ -8,11 +8,11 @@ import { eachSeries } from 'async'; import * as actionTypes from '../constants/actionTypes'; import * as currentState from '../reducers/initialState'; -export const getEDOList = ({ dispatch, update = false }) => +export const getEDOOperatorList = ({ dispatch, update = false }) => { - const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/list`; + const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/operators`; - console.log("ACTION", "edo", "getEDOList()", { url }); + console.log("ACTION", "edo", "getEDOOperatorList()", { url }); return new Promise((resolve, reject) => { @@ -21,10 +21,11 @@ export const getEDOList = ({ dispatch, update = false }) => }) .then((response) => { - console.log("ACTION", "edo", "getEDOList()", "response", response.data); + console.log("ACTION", "edo", "getEDOOperatorList()", "response", response.data); + /* dispatch({ - type: actionTypes.EDO_LIST, + type: actionTypes.EDO_OPERATORS_LIST, data: { list: [ { @@ -37,31 +38,98 @@ export const getEDOList = ({ dispatch, update = false }) => ] } }); + */ - /* dispatch({ - type: actionTypes.EDO_LIST, + type: actionTypes.EDO_OPERATORS_LIST, data: { - list: response.data + operators: response.data.box_edo } }); - */ resolve(); }) .catch((error) => { - console.error("ACTION", "edo", "getEDOList()", "ERROR"); + console.error("ACTION", "edo", "getEDOOperatorList()", "ERROR"); console.error(error); dispatch({ - type: actionTypes.EDO_LIST, + type: actionTypes.EDO_OPERATORS_LIST, data: { - list: [] + operators: [] } }); reject(); }); }); +} + +export const getEDOInvitesList = ({ dispatch, update = false }) => +{ + const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/invites`; + + console.log("ACTION", "edo", "getEDOInvitesList()", { url }); + + return new Promise((resolve, reject) => + { + axios.post(url, {}, { + withCredentials: true, + }) + .then((response) => + { + console.log("ACTION", "edo", "getEDOInvitesList()", "response", response.data); + + dispatch({ + type: actionTypes.EDO_INVITES_LIST, + data: { + invites: response.data.box_edo + } + }); + + resolve(); + }) + .catch((error) => + { + console.error("ACTION", "edo", "getEDOInvitesList()", "ERROR"); + console.error(error); + + dispatch({ + type: actionTypes.EDO_INVITES_LIST, + data: { + invites: [] + } + }); + + reject(); + }); + }); +} + +export const inviteToEDO = () => +{ + const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/edo/invite/send`; + + console.log("ACTION", "edo", "inviteToEDO()", { url }); + + return new Promise((resolve, reject) => + { + axios.post(url, {}, { + withCredentials: true, + }) + .then((response) => + { + console.log("ACTION", "edo", "inviteToEDO()", "response", response.data); + + resolve(response.data); + }) + .catch((error) => + { + console.error("ACTION", "edo", "inviteToEDO()", "ERROR"); + console.error(error); + + reject(error.data); + }); + }); } \ No newline at end of file diff --git a/actions/index.js b/actions/index.js index 8b8f996..2e6213c 100644 --- a/actions/index.js +++ b/actions/index.js @@ -14,4 +14,6 @@ export * from './adminActions'; export * from './suggestsActions'; export * from './questionnaireActions'; export * from './feedbackActions'; -export * from './dealsActions'; \ No newline at end of file +export * from './dealsActions'; +export * from './edoActions'; +export * from './signActions'; \ No newline at end of file diff --git a/actions/signActions.js b/actions/signActions.js new file mode 100644 index 0000000..df0fa7b --- /dev/null +++ b/actions/signActions.js @@ -0,0 +1,75 @@ +import axios from 'axios'; +import { Cookies } from 'react-cookie'; +import Router from 'next/router'; +import moment from 'moment'; +import { nSQL } from "@nano-sql/core"; +import { concatSeries, eachSeries } from 'async'; + +import * as actionTypes from '../constants/actionTypes'; +import * as currentState from '../reducers/initialState'; + +export const signCheckEDOCreatePrintForm = ({ contracts, sign_type }) => +{ + const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/check`; + + console.log("ACTION", "edo", "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); + }) + }); +} + +export const signGetGUIDEntity = ({ contract_number }) => +{ + const url = `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/sign/entity`; + + console.log("ACTION", "edo", "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); + }) + }); +} \ No newline at end of file diff --git a/components/DealsStatus/SingleDeal.js b/components/DealsStatus/SingleDeal.js index e5e90b8..4aef9b1 100644 --- a/components/DealsStatus/SingleDeal.js +++ b/components/DealsStatus/SingleDeal.js @@ -5,6 +5,8 @@ import { eachLimit } from "async"; import { SpinnerCircular } from "spinners-react"; import FileDropzoneDeals from "../FileDropzoneDeals"; +import EDOSign from "../../components/EDOSign"; + import { acceptDealOffers, attachDealDocument, removeDealDocument, sendDealDocuments } from "../../actions"; class Step extends React.Component @@ -654,7 +656,7 @@ class StatusDecisionMaking extends Step } } -class StatusLeasingRegistration extends Step +class StatusPositiveDecision extends Step { constructor(props) { @@ -687,13 +689,14 @@ class StatusLeasingRegistration extends Step } } -class SigningTypeSelection extends Step +class LeasingRegistration extends Step { constructor(props) { super(props); this.state = { open: false, + /* checked: { prepared_contracts: [], signing_plan_contracts: [], @@ -701,6 +704,9 @@ class SigningTypeSelection extends Step issued_contracts: [], annulled_contracts: [], }, + */ + checked: [], + edo: false, }; this.status = [ 107 ]; this.types = [ @@ -727,13 +733,63 @@ class SigningTypeSelection extends Step ]; } + _getEDODocuments = () => + { + const contracts = this.props.contracts['prepared_contracts']; + const { checked } = this.state; + const documents = []; + + for(let i in contracts) + { + if(checked.indexOf(contracts[i].name) > -1) + { + documents.push({ + id: contracts[i].name, + name: `Договор № ${ contracts[i].name }`, + date: contracts[i].date, + type: `${ contracts[i].brand_name } ${ contracts[i].model_name }`, + extension: 'pdf', + }) + } + } + + 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 checked = this.state.checked.prepared_contracts; + const { edo, checked } = this.state; + //const checked = this.state.checked.prepared_contracts; const contracts = this.props.contracts['prepared_contracts']; console.log("_render_preparedContracts", { contracts }); + if(edo) + { + return ( + this.setState({ edo: false }) } + /> + ) + } + return (
@@ -741,8 +797,8 @@ class SigningTypeSelection extends Step contracts.map((contract, index) => (
- -1 ? true : false } onChange={ () => {} }/> - + -1 ? true : false } onChange={ () => { this._handle_onPreparedContract(contract.name) } }/> +
{ moment(contract.date).format('MM.DD.YYYY') } { contract.brand_name } @@ -754,17 +810,20 @@ class SigningTypeSelection extends Step

Нет договоров

) }
-
- - -
+ { contracts.length > 0 && + ( +
+ + +
+ ) }
) } _render_signingPlanContracts = () => { - const contracts = this.props.contracts['prepared_contracts']; + const contracts = this.props.contracts['signing_plan_contracts']; console.log("_render_signingPlanContracts", { contracts }); return ( @@ -939,7 +998,7 @@ class SigningTypeSelection extends Step render() { const { index, statuscode_id, dealSelected } = this.props; - const { open } = this.state; + const { open, edo } = this.state; return (
-1 ? "current" : statuscode_id > this.status[ 0 ] ? "done" : "" }`}> @@ -948,16 +1007,30 @@ class SigningTypeSelection extends Step
{ this._renderHeader("Оформление лизинга") }
- { this.types.map((type, index) => ( -
-
-

{ type.title }

-
-
- { this._render_contracts(type.key) } -
+ { this.props.contracts === undefined ? ( +
+
- )) } + ) : ( + <> + { this.types.map((type, index) => ( +
+ { edo ? ( + <> + { type.key !== "prepared_contracts" && ( +

{ type.title }

+ ) } + + ) : ( +

{ type.title }

+ ) } +
+ { this._render_contracts(type.key) } +
+
+ )) } + + ) }
@@ -995,8 +1068,8 @@ export default class SingleDeal extends React.Component - - + +
Свернуть diff --git a/components/EDOSign/index.js b/components/EDOSign/index.js index 486be18..04503de 100644 --- a/components/EDOSign/index.js +++ b/components/EDOSign/index.js @@ -1,6 +1,9 @@ import React from "react"; import { connect } from "react-redux"; import moment from "moment"; +import { SpinnerCircular } from "spinners-react"; + +import { signCheckEDOCreatePrintForm } from "../../actions"; //import { getDeals, getDealOffers, getDealDocuments, getDealContracts } from "../../actions"; class EDOSign extends React.Component @@ -9,7 +12,7 @@ class EDOSign extends React.Component { super(props) this.state = { - list: null, + operators: null, loading: false, selected: {}, } @@ -19,7 +22,7 @@ class EDOSign extends React.Component { console.log("EDOSign", "getDerivedStateFromProps", { nextProps }); return { - list: nextProps.list, + operators: nextProps.operators, } } @@ -27,13 +30,36 @@ class EDOSign extends React.Component { if(this.state.selected.box_id === undefined) { - this.setState({ selected: this.state.list !== null && this.state.list[0] !== undefined ? this.state.list[0] : {} }); + this.setState({ selected: this.state.operators !== null && this.state.operators[0] !== undefined ? this.state.operators[0] : {} }); } } - _handle_onFormSubmit = () => + _handle_onFormSubmit = (event) => { + event.preventDefault(); + const { documents } = this.props; + const { selected } = this.state; + console.log("_handle_onFormSubmit"); + console.log({ documents, selected }); + + this.setState({ loading: true }, () => + { + const contracts = []; + for(let i in documents) + { + contracts.push(documents[i].id); + signCheckEDOCreatePrintForm({ contracts, sign_type: "EDO" }) + .then((checks) => + { + console.log({ checks }); + }) + .catch((error) => + { + console.log({ error }); + }); + } + }) } _handle_onSelectOperator = (operator) => @@ -43,29 +69,29 @@ class EDOSign extends React.Component render() { - const { list, loading, selected } = this.state; - const { onCancel, document } = this.props; - console.log({ list }); + const { operators, loading, selected } = this.state; + const { onCancel, documents } = this.props; + console.log({ operators, documents }); return ( - <> +

Подписание через ЭДО

-

- { document.name } - - { document.number } от{" "} { moment(document.date).format("DD.MM.YYYY") } - - { document.type !== undefined && ({ document.type }) } -

+ { documents.map((document, index) => + ( +

+ { document.name } от { moment(document.date).format("DD.MM.YYYY") } + { document.type !== undefined && ({ document.type }) } +

+ )) }
{if (e.key === 'Enter') e.preventDefault() }}>
- { list !== undefined && list !== null && list.map((operator, index) => ( + { operators !== undefined && operators !== null && operators.map((operator, index) => (
this._handle_onSelectOperator(operator) } disabled={ false } /> - +
)) }
@@ -89,7 +115,7 @@ class EDOSign extends React.Component
- +
) } } @@ -98,7 +124,7 @@ function mapStateToProps(state, ownProps) { console.log("EDOSign", "mapStateToProps", { state: state }); return { - list: state.edo.list, + operators: state.edo.operators, } } diff --git a/constants/actionTypes.js b/constants/actionTypes.js index 09e55ec..2d6638e 100644 --- a/constants/actionTypes.js +++ b/constants/actionTypes.js @@ -56,5 +56,6 @@ export const DEALS_RESET = 'DEALS_RESET'; export const DEAL_RESET = 'DEAL_RESET'; export const EDO_LOADED = 'EDO_LOADED'; -export const EDO_LIST = 'EDO_LIST'; +export const EDO_OPERATORS_LIST = 'EDO_OPERATORS_LIST'; +export const EDO_INVITES_LIST = 'EDO_INVITES_LIST'; export const EDO_RESET = 'EDO_RESET'; \ No newline at end of file diff --git a/css/main/style.css b/css/main/style.css index b40f314..3f8ec81 100644 --- a/css/main/style.css +++ b/css/main/style.css @@ -6216,21 +6216,47 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ .edo_detail p { margin: 0px; } +.edo_detail .list_title { + font-weight: 700 !important; + margin-bottom: 15px; + font-size: 15px; + line-height: 23px; +} .edo_list_field { + display: flex; + flex-wrap: wrap; align-items: flex-start !important; + margin-bottom: 30px; + width: 100%; +} +.edo_list_field label { + width: 186px; + margin-right: 12px; } .edo_list_selection { flex: 1; margin-top: -12px; } .edo_list_selection .item { + width: 100%; padding: 16px 0px; margin: 0px !important; border-bottom: solid 1px #edeff5; } +.edo_list_selection .item label { + width: auto; + display: flex; + align-items: center; + margin-right: 12px; +} .edo_list_selection .item label:first { margin-top: 0px; } +.edo_list_selection .item label:before { + top: 0; + bottom: 0; + margin: auto; +} .edo_list_selection .item:first { margin-top: 0px; } @@ -6243,3 +6269,36 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block .block_body .fines_ margin: 30px 0px !important; align-items: flex-start; } +.edo_operators_settings_list { + display: flex; + flex-direction: column; + align-content: flex-start; + gap: 15px 0px; +} +.edo_operators_settings_list_item { + margin-left: 40px; + display: flex; + flex-direction: column; + position: relative; +} +.edo_operators_settings_list_item a { + color: #8e94a7; + font-style: italic; +} +.edo_operators_settings_list_item:before { + content: ""; + position: absolute; + left: -40px; + top: -7px; + width: 24px; + min-width: 24px; + height: 30px; + min-height: 30px; + background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M16.125 9.75L10.625 15L7.875 12.375' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A"); + background-repeat: no-repeat; + background-position: center; + background-position-y: 6px; +} +.edo_operators_settings_list_item.invite:before { + background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z' stroke='%238E94A7' stroke-width='2' stroke-miterlimit='10'/%3E%3Cpath d='M12 6.75V12H17.25' stroke='%238E94A7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A"); +} diff --git a/css/main/style.less b/css/main/style.less index 2954950..e938e53 100644 --- a/css/main/style.less +++ b/css/main/style.less @@ -7161,10 +7161,26 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { p { margin: 0px; } + + .list_title { + font-weight: 700 !important; + margin-bottom: 15px; + font-size: 15px; + line-height: 23px; + } } .edo_list_field { + display: flex; + flex-wrap: wrap; align-items: flex-start !important; + margin-bottom: 30px; + width: 100%; + + label { + width: 186px; + margin-right: 12px; + } } .edo_list_selection { @@ -7172,16 +7188,27 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { margin-top: -12px; .item { + width: 100%; padding: 16px 0px; margin: 0px !important; border-bottom: solid 1px #edeff5; label { + width: auto; + display: flex; + align-items: center; + margin-right: 12px; // padding-top: 16px; &:first { margin-top: 0px; } + + &:before { + top: 0; + bottom: 0; + margin: auto; + } } &:first { @@ -7199,4 +7226,44 @@ main .dropdown_blocks_list.zero-margin.gibdd .dropdown_block { flex-direction: column; margin: 30px 0px !important; align-items: flex-start; +} + +.edo_operators_settings_list { + display: flex; + flex-direction: column; + align-content: flex-start; + gap: 15px 0px; +} + +.edo_operators_settings_list_item { + margin-left: 40px; + display: flex; + flex-direction: column; + position: relative; + + a { + color: #8e94a7; + font-style: italic; + } + + &:before { + content: ""; + position: absolute; + left: -40px; + top: -7px; + width: 24px; + min-width: 24px; + height: 30px; + min-height: 30px; + background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M16.125 9.75L10.625 15L7.875 12.375' stroke='%235FB158' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A"); + background-repeat: no-repeat; + background-position: center; + background-position-y: 6px; + } + + &.invite { + &:before { + background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z' stroke='%238E94A7' stroke-width='2' stroke-miterlimit='10'/%3E%3Cpath d='M12 6.75V12H17.25' stroke='%238E94A7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A"); + } + } } \ No newline at end of file diff --git a/lib/CRMRequestGet/index.js b/lib/CRMRequestGet/index.js index 218dc3a..b88722e 100644 --- a/lib/CRMRequestGet/index.js +++ b/lib/CRMRequestGet/index.js @@ -7,7 +7,7 @@ import jwt from 'jsonwebtoken'; import { cors } from '../cors'; import { inspect } from 'util'; -export default async function CRMRequestGet(req, res, path, params) +export default async function CRMRequestGet(req, res, path, params, log = false) { await cors(req, res); @@ -42,10 +42,11 @@ export default async function CRMRequestGet(req, res, path, params) //console.log("params", { ...client_jwt_decoded, ...params }); + const payload = { ...{ acc_number: client_jwt_decoded.acc_number }, ...params }; try { await axios.get(path, { - params: { ...{ acc_number: client_jwt_decoded.acc_number }, ...params }, + params: payload, headers: { "Authorization": `Bearer ${ crm_jwt }`, }, @@ -53,10 +54,12 @@ export default async function CRMRequestGet(req, res, path, params) }) .then((crm_response) => { - //console.log("crm_response for", path); - - //console.log(inspect(crm_response.data, true, null, true)); - + if(log) + { + console.log("crm_response for", path); + console.log("payload", payload); + console.log(inspect(crm_response.data, true, null, true)); + } res.status(200).json(crm_response.data); }) diff --git a/pages/api/contract/sign/cancel/check.js b/pages/api/contract/sign/cancel/check.js new file mode 100644 index 0000000..2ebc29f --- /dev/null +++ b/pages/api/contract/sign/cancel/check.js @@ -0,0 +1,22 @@ +import CRMRequestGet from '../../../../../lib/CRMRequestGet'; + +export default async function handler(req, res) +{ + console.log("API", "SIGN", "/cancel/check"); + + const { contract_number, sign_type } = req.body; + const payload = { + contract_number + }; + + if(sign_type === "EDO") + { + payload.doc_type_id = 144; + } + else + { + payload.doc_type_id = 60; + } + + await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/CheckCancelDocument`, payload); +} \ No newline at end of file diff --git a/pages/api/contract/sign/cancel/index.js b/pages/api/contract/sign/cancel/index.js new file mode 100644 index 0000000..97ed5f5 --- /dev/null +++ b/pages/api/contract/sign/cancel/index.js @@ -0,0 +1,22 @@ +import CRMRequestGet from '../../../../../lib/CRMRequestGet'; + +export default async function handler(req, res) +{ + console.log("API", "SIGN", "/cancel"); + + const { contract_number, sign_type } = req.body; + const payload = { + contract_number + }; + + if(sign_type === "EDO") + { + payload.doc_type_id = 144; + } + else + { + payload.doc_type_id = 60; + } + + await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/CancelDocument`, payload); +} \ No newline at end of file diff --git a/pages/api/contract/sign/check.js b/pages/api/contract/sign/check.js new file mode 100644 index 0000000..d40d36b --- /dev/null +++ b/pages/api/contract/sign/check.js @@ -0,0 +1,14 @@ +import CRMRequestGet from '../../../../lib/CRMRequestGet'; + +export default async function handler(req, res) +{ + console.log("API", "SIGN", "/check"); + + const { contract_number, sign_type } = req.body; + const payload = { + contract_number, + sign_type + }; + + await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/CheckCreatePrintForm`, payload); +} \ No newline at end of file diff --git a/pages/api/contract/sign/document.js b/pages/api/contract/sign/document.js new file mode 100644 index 0000000..86d2342 --- /dev/null +++ b/pages/api/contract/sign/document.js @@ -0,0 +1,26 @@ +import CRMRequestGet from '../../../lib/CRMRequestGet'; + +export default async function handler(req, res) +{ + console.log("API", "SIGN", "/document"); + + const { entityName, entityId, sign_type } = req.body; + const payload = { + entityName, + entityId, + reportCodes: [ "Leas_Contract" ], + inputParameters: [ sign_type ], + createDocument: true, + }; + + if(sign_type === "EDO") + { + payload.documentTypeEvoId = 144; + } + else + { + payload.documentTypeEvoId = 60; + } + + await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/File/GetWMDoc`, payload); +} \ No newline at end of file diff --git a/pages/api/contract/sign/entity.js b/pages/api/contract/sign/entity.js new file mode 100644 index 0000000..d7f7b5a --- /dev/null +++ b/pages/api/contract/sign/entity.js @@ -0,0 +1,13 @@ +import CRMRequestGet from '../../../../lib/CRMRequestGet'; + +export default async function handler(req, res) +{ + console.log("API", "SIGN", "/entity"); + + const { contract_number } = req.body; + const payload = { + contract_number + }; + + await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Contract/GetGUIDEntity`, payload); +} \ No newline at end of file diff --git a/pages/api/edo/invite/send.js b/pages/api/edo/invite/send.js index eec679b..ece1b58 100644 --- a/pages/api/edo/invite/send.js +++ b/pages/api/edo/invite/send.js @@ -1,3 +1,12 @@ /* 2.8.3 - Метод отправки Приглашения Клиенту(для ЭДО) (lk/Account/InviteEdoBox) */ + +import CRMRequestGet from '../../../../lib/CRMRequestGet'; + +export default async function handler(req, res) +{ + console.log("API", "EDO", "/invite/send"); + + await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Account/InviteEdoBox`, {}); +} \ No newline at end of file diff --git a/pages/api/edo/invites.js b/pages/api/edo/invites.js new file mode 100644 index 0000000..91e7ad1 --- /dev/null +++ b/pages/api/edo/invites.js @@ -0,0 +1,11 @@ +/* +2.8.1 - Метод получения доступных для работы в ЭДО ящиков (lk/Account/GetEdoBox) +*/ +import CRMRequestGet from '../../../lib/CRMRequestGet'; + +export default async function handler(req, res) +{ + console.log("API", "EDO", "/invites"); + + await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Account/GetInviteEdoBox`, {}); +} \ No newline at end of file diff --git a/pages/api/edo/list.js b/pages/api/edo/operators.js similarity index 88% rename from pages/api/edo/list.js rename to pages/api/edo/operators.js index 767ba09..f409e94 100644 --- a/pages/api/edo/list.js +++ b/pages/api/edo/operators.js @@ -5,7 +5,7 @@ import CRMRequestGet from '../../../lib/CRMRequestGet'; export default async function handler(req, res) { - console.log("API", "EDO", "/list"); + console.log("API", "EDO", "/operators"); await CRMRequestGet(req, res, `${ process.env.CRM_API_HOST }/lk/Account/GetEdoBox`, {}); } \ No newline at end of file diff --git a/pages/contract/agreement.js b/pages/contract/agreement.js index 0eb9e93..d989ab0 100644 --- a/pages/contract/agreement.js +++ b/pages/contract/agreement.js @@ -190,7 +190,7 @@ class ContractPage extends React.Component ) : ( <> { edo_mode ? ( - this.setState({ edo_mode: false }) }/> + this.setState({ edo_mode: false }) }/> ) : (
{ unsigned !== undefined && unsigned !== null && unsigned.documents !== undefined && unsigned.documents !== null && unsigned.count > 0 && ( diff --git a/pages/settings/digital.js b/pages/settings/digital.js index 5e9fde3..8696aef 100644 --- a/pages/settings/digital.js +++ b/pages/settings/digital.js @@ -20,9 +20,9 @@ import Footer from '../components/Footer'; import Pagination from '../components/Pagination'; import Company from "../components/Company"; -import { sendPhoneChangeNumber, sendPhoneChangeNumberSmsCode, setUserPhone } from '../../actions'; +import { inviteToEDO, sendPhoneChangeNumber, sendPhoneChangeNumberSmsCode, setUserPhone } from '../../actions'; import AccountLayout from "../components/Layout/Account"; -import { getEDOList } from "../../actions/edoActions"; +import { getEDOOperatorList, getEDOInvitesList } from "../../actions"; class IndexPage extends React.Component { @@ -32,22 +32,20 @@ class IndexPage extends React.Component this.state = { loading: false, operator: undefined, - oparators: [ - { "value": "1", "label": "Диадок" }, - { "value": "2", "label": "Такском" }, - { "value": "3", "label": "Тензор" }, - { "value": "4", "label": "Калуга Астрал" }, - { "value": "5", "label": "КОРУС Консалтинг" }, - { "value": "6", "label": "АйтиКом" }, - ] + operators: null, + invites: null, + message: undefined, }; } static getDerivedStateFromProps(nextProps, prevState) { + console.log("getDerivedStateFromProps", "edo", "operators", nextProps.operators); return { observer: nextProps.observer, user: nextProps.user, + operators: nextProps.operators, + invites: nextProps.operators, }; } @@ -55,20 +53,27 @@ class IndexPage extends React.Component { const { dispatch } = this.props; - getEDOList({ dispatch }) - .then(() => - { - - }) - .catch(() => - { - - }); + getEDOOperatorList({ dispatch }).then(() => {}).catch(() => {}); + getEDOInvitesList({ dispatch }).then(() => {}).catch(() => {}); } _handle_onFormSubmit = (event) => { event.preventDefault(); + + console.log("_handle_onFormSubmit"); + this.setState({ loading: true }, () => + { + inviteToEDO() + .then((message) => + { + this.setState({ message }) + }) + .catch(() => + { + this.setState({ message }) + }); + }) } _handle_onOperatorChange = (operator) => @@ -78,8 +83,11 @@ class IndexPage extends React.Component render() { - const { user, oparators, operator, loading, } = this.state; + const { user, operators, invites, operator, loading, message } = this.state; + var list = operators !== null && invites !== null ? [ ...operators, ...invites ] : null; + + console.log({ operators }); return ( @@ -101,33 +109,66 @@ class IndexPage extends React.Component
+ {/*}

Выберите своего оператора. Мы отправим вашей организации приглашение.

-


-
{if (e.key === 'Enter') e.preventDefault() }}> -
- - !inputValue ? "" :"Ничего не найдено" } + isSearchable={ true } + className="autocomlete autocomlete_with_indicators" + classNamePrefix="react-select" + value={ operator !== undefined ? operator : undefined } + onChange={ (element) => { this._handle_onOperatorChange(element) } } + required={ true } + /> + {*/} +
+
+ +
+
+ ) : ( +

{ message }

+ ) } + + ) : ( +
+
-
- -
- + ) }
@@ -140,9 +181,11 @@ class IndexPage extends React.Component function mapStateToProps(state, ownProps) { + console.log("mapStateToProps", "operators", { edo: state.edo }); return { observer: state.auth.observer, user: state.user, + operators: state.edo.operators, } } diff --git a/reducers/edoReducer.js b/reducers/edoReducer.js index 2158d1e..2c26555 100644 --- a/reducers/edoReducer.js +++ b/reducers/edoReducer.js @@ -15,17 +15,17 @@ const edoReducer = (state = initialState.edo, action) => }; } - case actionTypes.EDO_LIST: + case actionTypes.EDO_OPERATORS_LIST: { - console.log("actionTypes.EDO_LIST", actionTypes.EDO_LIST, { action }); + console.log("actionTypes.EDO_OPERATORS_LIST", actionTypes.EDO_OPERATORS_LIST, { action }); console.log({ ...state, - list: action.data.list, + operators: action.data.operators, }); return { ...state, - list: action.data.list, + operators: action.data.operators, }; } @@ -33,7 +33,7 @@ const edoReducer = (state = initialState.edo, action) => { return { loaded: false, - list: null, + operators: null, }; } diff --git a/reducers/initialState.js b/reducers/initialState.js index 387d84c..f6eab6e 100644 --- a/reducers/initialState.js +++ b/reducers/initialState.js @@ -255,7 +255,8 @@ export const defaultState = { edo: { loaded: false, - list: null, + operators: null, + invites: null, } };