fix object for mutation

This commit is contained in:
Chika 2020-11-15 22:14:55 +03:00
parent 7c8ac4b936
commit 02227ba75b
4 changed files with 24 additions and 12 deletions

View File

@ -143,7 +143,6 @@ class CalculationService {
variables,
}: IMutateToCRMGQL): Promise<IGetEntitiesResponse> =>
new Promise(async (resolve, reject) => {
console.log(mutation);
await client
.mutate({
mutation,

View File

@ -585,7 +585,7 @@ export const prepareCalculationData = ({
const tarif = options.selectTarif?.find(x => x.evo_tarifid === values.tarif);
if (tarif) {
preparedValues.iRR_MSFO_Plan = (tarif.evo_irr_plan || 0) / 100;
preparedValues.irr_MSFO_Plan = (tarif.evo_irr_plan || 0) / 100;
}
const evo_coefficient_risk = calculationStore
@ -735,7 +735,7 @@ export const prepareCalculationData = ({
firstPaymentSum;
return {
preparedPayments: { Rows: preparedPaymentsRows },
preparedPayments: { rows: preparedPaymentsRows },
preparedValues,
};
};

View File

@ -9,6 +9,7 @@ import { getUser } from 'client/tools/user';
import { TAction } from 'core/types/Calculation/Store/effect';
import { ITableCell } from 'core/types/Calculation/Store/tables';
import { TableProps } from './../../../../core/types/Calculation/Store/tables';
import { Status } from 'core/types/statuses';
const actions: TAction = {
createLead: () => {
@ -157,7 +158,7 @@ const actions: TAction = {
createKP: async () => {
const { values } = CalculationStore;
console.log(actions);
console.log('values', values);
const calculationRes = await actions.calculate();
console.log('calculationRes', calculationRes);
@ -174,11 +175,11 @@ const actions: TAction = {
CalculationService.crmgqlmutaion({
mutation: gql`
mutation CreateOffer(
$postValues: PostValuesInput!
$columns: CalculationColumnsInput!
$preparedValues: PreparedValuesInput!
$preparedPayments: PreparedPaymentsInput!
$values: CalculationValuesInput!
$postValues: PostValuesInput
$columns: CalculationColumnsInput
$preparedValues: PreparedValuesInput
$preparedPayments: PreparedPaymentsInput
$values: CalculationValuesInput
$domainName: String
) {
createBy(domainName: $domainName) {
@ -214,8 +215,15 @@ const actions: TAction = {
},
calculate: async () => {
// TODO: block button for time
// TODO: collect errors
CalculationStore.setStatus('btnCreateKP', Status.Loading);
setTimeout(() => {
CalculationStore.setStatus('btnCreateKP', Status.Default);
}, 3500);
CalculationStore.setStatus('btnCalculate', Status.Loading);
setTimeout(() => {
CalculationStore.setStatus('btnCalculate', Status.Default);
}, 3500);
const { rows } = CalculationStore.tables.tableInsurance;
const kaskoRow = rows[1];
@ -279,6 +287,11 @@ const actions: TAction = {
console.log(preparedData);
CalculationStore.setStatus('btnCalculate', Status.Loading);
setTimeout(() => {
CalculationStore.setStatus('btnCalculate', Status.Default);
}, 3500);
CalculationStore.cleanTable('tableResults');
return CalculationService.calculate(preparedData)

View File

@ -84,7 +84,7 @@ export interface PreparedValues {
acquisitionExpenses?: number;
npvBase?: number;
tLMCost?: number;
iRR_MSFO_Plan?: number;
irr_MSFO_Plan?: number;
extraBonus?: number;
directorBonus?: number;
dogCredit?: number;
@ -101,4 +101,4 @@ export interface PaymentRow {
tlmCostPayment?: number;
}
export type PreparedPayments = { Rows: PaymentRow[] };
export type PreparedPayments = { rows: PaymentRow[] };