diff --git a/actions/contractActions.js b/actions/contractActions.js index f936946..85186c5 100644 --- a/actions/contractActions.js +++ b/actions/contractActions.js @@ -491,8 +491,8 @@ export const getContractGraphicChangeCalculate = (calculation) => return new Promise((resolve, reject) => { - - axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/change/graphic/calculate`, { calculation }, + + axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/change/graphic/calculate`, calculation, { withCredentials: true, }) diff --git a/pages/api/contract/change/graphic/calculate.js b/pages/api/contract/change/graphic/calculate.js index e5ed656..a498d9a 100644 --- a/pages/api/contract/change/graphic/calculate.js +++ b/pages/api/contract/change/graphic/calculate.js @@ -5,5 +5,5 @@ export default async function handler(req, res) { console.log("WTF BODY"); console.log(req.body); - await CRMRequestPost(req, res, `${ process.env.CRM_API_HOST }/lk/add-contract/CreateCalculation`, req.body.calculation); + await CRMRequestPost(req, res, `${ process.env.CRM_API_HOST }/lk/add-contract/CreateCalculation?contract_number=${ req.body.contract_number }`, req.body); } \ No newline at end of file diff --git a/pages/contract/__change.js b/pages/contract/__change.js index 25c5689..13d45cc 100644 --- a/pages/contract/__change.js +++ b/pages/contract/__change.js @@ -223,7 +223,7 @@ class ChangeGraphicPage extends React.Component
@@ -248,13 +248,13 @@ class ChangeGraphicPage extends React.Component
diff --git a/pages/contract/change/components/Options/index.js b/pages/contract/change/components/Options/index.js index ab1b2dd..8300296 100644 --- a/pages/contract/change/components/Options/index.js +++ b/pages/contract/change/components/Options/index.js @@ -104,7 +104,7 @@ class FixLastPayment extends React.Component
@@ -516,6 +516,18 @@ export default class Options extends React.Component event.preventDefault(); console.log(this.props); + const selected = { + number_planpayment: options.number_planpayment.value, + }; + if(number_paydate !== null) { selected.number_paydate = moment(number_paydate).format(); } + if(period_new !== null) { selected.period_new = period_new; } + if(fix_last_payment_available !== null) { selected.fix_last_payment_available = fix_last_payment_available; } + if(date_offset_type !== null) { selected.date_offset_type = date_offset_type; } + if(sum !== null) { selected.sum = sum; } + if(insurance_price_result !== null) { selected.insurance_price_result = insurance_price_result; } + //if(early_redemption_change !== null) { selected.early_redemption_change = early_redemption_change; } + if(datefrom !== null) { selected.datefrom = moment(datefrom).format(); } + if(!sending) { const v = {}; @@ -523,17 +535,7 @@ export default class Options extends React.Component const payload = { ...{ contract_number: number }, ...v, - ...{ - number_paydate: number_paydate !== null ? moment(number_paydate).format() : null, - period_new, - fix_last_payment_available, - date_offset_type, - sum: sum === null ? 0 : sum, - insurance_price_result: insurance_price_result === null ? 0 : insurance_price_result, - datefrom: datefrom !== null ? moment(datefrom).format() : null, - early_redemption_change: false, - number_planpayment: options.number_planpayment.value, - } + ...selected }; console.log(payload); @@ -545,20 +547,11 @@ export default class Options extends React.Component console.log("calculationcalculationcalculationcalculationcalculation"); console.log(calculation); - /* - onCalculate() - .then(() => - { - - }) - .catch(() => - { - this.setState({ sending: false, }); - }); - */ + onCalculate(calculation.addcontract_number); }) .catch(() => { + this.setState({ sending: false, }); }); }); } diff --git a/pages/contract/change/index.js b/pages/contract/change/index.js index 411daad..811b59c 100644 --- a/pages/contract/change/index.js +++ b/pages/contract/change/index.js @@ -23,12 +23,13 @@ import VariantsList from "./components/VariantsList"; import Final from "./components/Final"; import { - getContractInfo, - getContractGraphicChange, - getContractGraphicChangeVariants, - getContractGraphicChangeGetCurrent, - getContractGraphicChangeGetCalculated, - getContractGraphicChangeSignatories, + getContractInfo, + getContractGraphicChange, + getContractGraphicChangeVariants, + getContractGraphicChangeGetCurrent, + getContractGraphicChangeGetCalculated, + getContractGraphicChangeSignatories, + getContractGraphicChangeCalculationsList, } from "../../../actions"; import Options from "./components/Options"; import Comparison from "./components/Comparison"; @@ -204,9 +205,21 @@ class ChangeGraphicPage extends React.Component this.setState({ signer: signer_id }); } - _handle_onCalculate = () => + _handle_onCalculate = (calculation_id) => { - this.setState({ mode_options: false, mode_comparison: true }); + const { dispatch, number } = this.props; + + getContractGraphicChangeCalculationsList({ dispatch, number }) + .then(() => + { + setTimeout(() => + { + this._handle_onCalculation(calculation_id); + }, 100); + }) + .catch(() => + { + }); } _handle_onCalculation = (calculation_id) =>