actions(createKP): set pdf url after createKP

This commit is contained in:
Chika 2022-01-17 13:04:40 +03:00
parent df1c732521
commit 60adb72e26

View File

@ -2,6 +2,7 @@ import { message } from 'antd';
import { AxiosError } from 'axios'; import { AxiosError } from 'axios';
import { openNotification } from 'client/Elements/Notification'; import { openNotification } from 'client/Elements/Notification';
import UserStore from 'client/stores/UserStore'; import UserStore from 'client/stores/UserStore';
import { CRM_PROXY_URL } from 'core/constants/urls';
import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote'; import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote';
import CrmService from 'core/services/CrmService'; import CrmService from 'core/services/CrmService';
import { ICalculationStore } from 'core/types/Calculation/Store'; import { ICalculationStore } from 'core/types/Calculation/Store';
@ -56,12 +57,17 @@ export default async function (this: ICalculationStore) {
const payload = await composeRequest.call(this); const payload = await composeRequest.call(this);
if (!payload) return; if (!payload) return;
await CrmService.createKP(payload); const { data: newKP } = await CrmService.createKP(payload);
message.success({ 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>({ CrmService.getCRMOptions<'quotes', IQuote>({
query: getQuotesByLeadQuery, query: getQuotesByLeadQuery,
variables: { variables: {
@ -69,10 +75,7 @@ export default async function (this: ICalculationStore) {
}, },
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
}).then(({ quotes }) => { }).then(({ quotes }) => {
if (!quotes || quotes?.length === 0) { if (!quotes || quotes?.length === 0) throw new Error();
throw new Error();
}
this.setOptions('selectQuote', quotes); this.setOptions('selectQuote', quotes);
}); });
} catch (err) { } catch (err) {