trpc/create-kp: add downloadKp url to result
This commit is contained in:
parent
79179c10f3
commit
06e7687fc1
1
.env
1
.env
@ -6,6 +6,7 @@ BASE_PATH=
|
||||
URL_GET_USER_DIRECT=
|
||||
URL_CRM_GRAPHQL_DIRECT=
|
||||
URL_CRM_CREATEKP_DIRECT=
|
||||
URL_CRM_DOWNLOADKP_BASE=
|
||||
URL_CORE_FINGAP_DIRECT=
|
||||
URL_CORE_CALCULATE_DIRECT=
|
||||
URL_1C_TRANSTAX_DIRECT=
|
||||
@ -139,7 +139,7 @@ const elementsToValues = wrapElementsMap({
|
||||
selectLeasingWithoutKasko: 'leasingWithoutKasko',
|
||||
|
||||
/** Link Elements */
|
||||
linkDownloadKp: 'kpUrl',
|
||||
linkDownloadKp: 'downloadKp',
|
||||
linkLeadUrl: 'leadUrl',
|
||||
linkOpportunityUrl: 'opportunityUrl',
|
||||
linkQuoteUrl: 'quoteUrl',
|
||||
|
||||
@ -29,6 +29,11 @@ export type RequestCreateKP = z.infer<typeof RequestCreateKPSchema>;
|
||||
export const ResponseCreateKPSchema = z.union([
|
||||
z.object({
|
||||
evo_quotename: z.string(),
|
||||
link: z.string(),
|
||||
name: z.string(),
|
||||
offerprintform: z.string(),
|
||||
offerprintformapi: z.string(),
|
||||
quoteid: z.string(),
|
||||
success: z.literal(true),
|
||||
}),
|
||||
z.object({
|
||||
|
||||
@ -35,6 +35,7 @@ const defaultValues: CalculationValues = {
|
||||
depreciationGroup: '-',
|
||||
disableChecks: false,
|
||||
discountRub: 0,
|
||||
downloadKp: null,
|
||||
engineHours: 0,
|
||||
engineType: 100_000_000,
|
||||
engineVolume: 0,
|
||||
|
||||
@ -7,6 +7,7 @@ const envSchema = z.object({
|
||||
URL_CORE_CALCULATE_DIRECT: z.string(),
|
||||
URL_CORE_FINGAP_DIRECT: z.string(),
|
||||
URL_CRM_CREATEKP_DIRECT: z.string(),
|
||||
URL_CRM_DOWNLOADKP_BASE: z.string(),
|
||||
URL_CRM_GRAPHQL_DIRECT: z.string(),
|
||||
URL_GET_USER_DIRECT: z.string(),
|
||||
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
||||
|
||||
@ -12,6 +12,7 @@ const serverRuntimeConfigSchema = envSchema.pick({
|
||||
URL_CORE_CALCULATE_DIRECT: true,
|
||||
URL_CORE_FINGAP_DIRECT: true,
|
||||
URL_CRM_CREATEKP_DIRECT: true,
|
||||
URL_CRM_DOWNLOADKP_BASE: true,
|
||||
URL_CRM_GRAPHQL_DIRECT: true,
|
||||
URL_GET_USER_DIRECT: true,
|
||||
});
|
||||
|
||||
@ -128,6 +128,7 @@ const ValuesSchema = z.object({
|
||||
/**
|
||||
* Link Values
|
||||
*/
|
||||
downloadKp: z.string().nullable(),
|
||||
kpUrl: z.string().nullable(),
|
||||
leadUrl: z.string().nullable(),
|
||||
opportunityUrl: z.string().nullable(),
|
||||
|
||||
@ -16,6 +16,7 @@ function getUrls() {
|
||||
URL_1C_TRANSTAX_DIRECT,
|
||||
URL_CORE_CALCULATE_DIRECT,
|
||||
URL_CRM_CREATEKP_DIRECT,
|
||||
URL_CRM_DOWNLOADKP_BASE,
|
||||
PORT,
|
||||
} = serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
||||
|
||||
@ -26,6 +27,7 @@ function getUrls() {
|
||||
URL_CORE_CALCULATE: URL_CORE_CALCULATE_DIRECT,
|
||||
URL_CORE_FINGAP: URL_CORE_FINGAP_DIRECT,
|
||||
URL_CRM_CREATEKP: URL_CRM_CREATEKP_DIRECT,
|
||||
URL_CRM_DOWNLOADKP_BASE,
|
||||
URL_CRM_GRAPHQL: URL_CRM_GRAPHQL_DIRECT,
|
||||
URL_GET_USER: URL_GET_USER_DIRECT,
|
||||
};
|
||||
|
||||
@ -87,6 +87,7 @@ export function transformCalculateResults({
|
||||
|
||||
const values: OutputData['values'] = {
|
||||
IRR_Perc: columns?.cashflowMsfoColumn?.nominal * 100,
|
||||
downloadKp: null,
|
||||
lastPaymentRub: last(columns?.sumWithVatColumn?.values) || 0,
|
||||
totalPayments: columns?.sumWithVatColumn?.values[0] - inputValues.subsidySum,
|
||||
};
|
||||
|
||||
@ -22,6 +22,7 @@ export const OutputDataSchema = z.object({
|
||||
resultValues: ResultValuesSchema,
|
||||
values: ValuesSchema.pick({
|
||||
IRR_Perc: true,
|
||||
downloadKp: true,
|
||||
lastPaymentRub: true,
|
||||
totalPayments: true,
|
||||
}),
|
||||
|
||||
@ -17,6 +17,7 @@ import type { User } from '@/api/user/types';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import defaultValues from '@/config/default-values';
|
||||
import * as insuranceTable from '@/config/tables/insurance-table';
|
||||
import getUrls from '@/config/urls';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import * as addProduct from '@/process/add-product';
|
||||
import * as bonuses from '@/process/bonuses';
|
||||
@ -46,6 +47,8 @@ const defaultInsurance = {
|
||||
const defaultFingap = { keys: [] };
|
||||
const defaultPayments = { values: [] };
|
||||
|
||||
const { URL_CRM_DOWNLOADKP_BASE } = getUrls();
|
||||
|
||||
export const quoteRouter = router({
|
||||
getQuote: publicProcedure
|
||||
.input(GetQuoteInputDataSchema)
|
||||
@ -158,6 +161,10 @@ export const quoteRouter = router({
|
||||
responseCalculate: calculateResult,
|
||||
});
|
||||
|
||||
if (URL_CRM_DOWNLOADKP_BASE) {
|
||||
result.values.downloadKp = URL_CRM_DOWNLOADKP_BASE?.concat(createKPResult.evo_quotename);
|
||||
}
|
||||
|
||||
return {
|
||||
data: result,
|
||||
success: true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user