From 60adb72e264cb6d6c744035da4738bb2fd259ae9 Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 17 Jan 2022 13:04:40 +0300 Subject: [PATCH] actions(createKP): set pdf url after createKP --- .../Effects/actions/createKP.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/actions/createKP.ts b/src/client/stores/CalculationStore/Effects/actions/createKP.ts index 5d8777f..79b6dd4 100644 --- a/src/client/stores/CalculationStore/Effects/actions/createKP.ts +++ b/src/client/stores/CalculationStore/Effects/actions/createKP.ts @@ -2,6 +2,7 @@ import { message } from 'antd'; import { AxiosError } from 'axios'; import { openNotification } from 'client/Elements/Notification'; import UserStore from 'client/stores/UserStore'; +import { CRM_PROXY_URL } from 'core/constants/urls'; import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote'; import CrmService from 'core/services/CrmService'; import { ICalculationStore } from 'core/types/Calculation/Store'; @@ -56,12 +57,17 @@ export default async function (this: ICalculationStore) { const payload = await composeRequest.call(this); if (!payload) return; - await CrmService.createKP(payload); + const { data: newKP } = await CrmService.createKP(payload); message.success({ - content: 'КП создано!', + content: 'КП создано! ' + newKP?.evo_quotename, }); - const leadid = this.getValue('lead'); + if (newKP?.offerprintformapi) + this.stores.calculationUrls.setUrl({ + name: 'kpUrl', + url: String.prototype.concat(CRM_PROXY_URL, newKP?.offerprintformapi), + }); + const leadid = this.getValue('lead'); CrmService.getCRMOptions<'quotes', IQuote>({ query: getQuotesByLeadQuery, variables: { @@ -69,10 +75,7 @@ export default async function (this: ICalculationStore) { }, fetchPolicy: 'network-only', }).then(({ quotes }) => { - if (!quotes || quotes?.length === 0) { - throw new Error(); - } - + if (!quotes || quotes?.length === 0) throw new Error(); this.setOptions('selectQuote', quotes); }); } catch (err) {