From fe614b2529d42be876885f89c0b3f9f22131eef5 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 1 Jun 2023 15:13:31 +0300 Subject: [PATCH] fix: resetValues after get calculate results --- apps/web/process/calculate/reactions/common.ts | 13 ++++++++++++- apps/web/process/fingap/reactions/common.ts | 6 ++++-- apps/web/stores/tables/insurance/index.ts | 4 ++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/web/process/calculate/reactions/common.ts b/apps/web/process/calculate/reactions/common.ts index f44e88b..2d8cc72 100644 --- a/apps/web/process/calculate/reactions/common.ts +++ b/apps/web/process/calculate/reactions/common.ts @@ -52,7 +52,18 @@ export default function reactions({ store, apolloClient }: ProcessContext) { osago: $tables.insurance.row('osago').getValues(), }, payments: $tables.payments.getValues, - values: omit(values, ['IRR_Perc', 'downloadKp', 'lastPaymentRub', 'pi', 'totalPayments']), + values: omit(values, [ + 'IRR_Perc', + 'irrInfo', + 'downloadKp', + 'lastPaymentRub', + 'lastPaymentPerc', + 'pi', + 'totalPayments', + 'tarif', + 'rate', + 'creditRate', + ]), }; }, () => { diff --git a/apps/web/process/fingap/reactions/common.ts b/apps/web/process/fingap/reactions/common.ts index adf1d65..2034536 100644 --- a/apps/web/process/fingap/reactions/common.ts +++ b/apps/web/process/fingap/reactions/common.ts @@ -4,6 +4,7 @@ import type { Risk } from '@/Components/Calculation/Form/Insurance/FinGAPTable/t import { STALE_TIME } from '@/constants/request'; import type * as CRMTypes from '@/graphql/crm.types'; import type { ProcessContext } from '@/process/types'; +import { disposableReaction } from '@/utils/mobx'; import { gql } from '@apollo/client'; import type { QueryFunctionContext } from '@tanstack/react-query'; import dayjs from 'dayjs'; @@ -14,7 +15,7 @@ import { flatten } from 'tools/object'; dayjs.extend(utc); export default function reactions({ store, apolloClient, queryClient }: ProcessContext) { - const { $calculation, $tables } = store; + const { $calculation, $tables, $process } = store; // Расчет итоговой суммы ФинГАП и запись в таблицу страхования reaction( () => $tables.fingap.totalSum, @@ -112,7 +113,8 @@ export default function reactions({ store, apolloClient, queryClient }: ProcessC // Заполнение таблицы рисков ФинГАП + Запрос расчета финГАП в мозжечок - reaction( + disposableReaction( + () => $process.has('Calculate'), () => { const finGAPInsuranceCompany = $tables.insurance.row('fingap').getValue('insuranceCompany'); const paymentsValues = toJS($tables.payments.values); diff --git a/apps/web/stores/tables/insurance/index.ts b/apps/web/stores/tables/insurance/index.ts index bc8011a..605fc6d 100644 --- a/apps/web/stores/tables/insurance/index.ts +++ b/apps/web/stores/tables/insurance/index.ts @@ -3,7 +3,7 @@ import type { ValidationParams } from '../../validation/types'; import type * as Insurance from '@/Components/Calculation/Form/Insurance/InsuranceTable/types'; import * as insuranceTableConfig from '@/config/tables/insurance-table'; import type RootStore from '@/stores/root'; -import { makeAutoObservable } from 'mobx'; +import { makeAutoObservable, toJS } from 'mobx'; export type InsuranceTableData = { options?: Record; @@ -124,7 +124,7 @@ export default class InsuranceTable { getValues: () => { const rowIndex = this.values.findIndex((x) => x.key === key); - return this.values[rowIndex]; + return toJS(this.values[rowIndex]); }, reset: (valueName: Insurance.Values) => {