load-kp: beautify typings

This commit is contained in:
vchikalkin 2023-02-27 22:40:10 +03:00
parent 08b474c128
commit 9d2c8d9bf8
18 changed files with 183 additions and 155 deletions

View File

@ -33,31 +33,37 @@ export const defaultOptions: Record<Insurance.Keys, Insurance.RowOptions> = {
fingap: defaultRowOptions,
};
export const DEFAULT_OSAGO_ROW: Insurance.RowValues = {
key: 'osago',
policyType: 'ОСАГО',
insuranceCompany: null,
insured: 100_000_000,
insCost: 0,
insTerm: 100_000_000,
};
export const DEFAULT_KASKO_ROW: Insurance.RowValues = {
key: 'kasko',
policyType: 'КАСКО',
insuranceCompany: null,
insured: 100_000_000,
insCost: 0,
insTerm: null,
};
export const DEFAULT_FINGAP_ROW: Insurance.RowValues = {
key: 'fingap',
policyType: 'Safe Finance',
insuranceCompany: null,
insured: 100_000_000,
insCost: 0,
insTerm: null,
};
export const defaultValues: Insurance.RowValues[] = [
{
key: 'osago',
policyType: 'ОСАГО',
insuranceCompany: null,
insured: 100_000_000,
insCost: 0,
insTerm: 100_000_000,
},
{
key: 'kasko',
policyType: 'КАСКО',
insuranceCompany: null,
insured: 100_000_000,
insCost: 0,
insTerm: null,
},
{
key: 'fingap',
policyType: 'Safe Finance',
insuranceCompany: null,
insured: 100_000_000,
insCost: 0,
insTerm: null,
},
DEFAULT_OSAGO_ROW,
DEFAULT_KASKO_ROW,
DEFAULT_FINGAP_ROW,
];
export const defaultStatuses: Record<Insurance.Keys, Insurance.RowStatuses> = {

View File

@ -419,7 +419,7 @@ export type GetQuoteFingapDataQueryVariables = Exact<{
}>;
export type GetQuoteFingapDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_fingap_accountid: string | null, evo_fingap_payer: number | null, evo_fingap_period: number | null, evo_product_risks: Array<{ __typename?: 'evo_product_risk', evo_addproduct_typeid: string | null } | null> | null } | null };
export type GetQuoteFingapDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_product_risks: Array<{ __typename?: 'evo_product_risk', evo_addproduct_typeid: string | null } | null> | null } | null };
export type GetFinGapAddProductTypesQueryVariables = Exact<{
currentDate: InputMaybe<Scalars['DateTime']>;
@ -449,6 +449,13 @@ export type GetInsuranceDataQueryVariables = Exact<{
export type GetInsuranceDataQuery = { __typename?: 'Query', osago: Array<{ __typename?: 'account', value: string | null, label: string | null } | null> | null, kasko: Array<{ __typename?: 'account', value: string | null, label: string | null } | null> | null, fingap: Array<{ __typename?: 'account', value: string | null, label: string | null } | null> | null };
export type GetQuoteInsuranceDataQueryVariables = Exact<{
quoteId: Scalars['Uuid'];
}>;
export type GetQuoteInsuranceDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_osago_accountid: string | null, evo_osago_payer: number | null, evo_osago_price: number | null, evo_kasko_accountid: string | null, evo_kasko_payer: number | null, evo_kasko_price: number | null, evo_insurance_period: number | null, evo_fingap_accountid: string | null, evo_fingap_payer: number | null, evo_fingap_period: number | null } | null };
export type GetLeadUrlQueryVariables = Exact<{
id: Scalars['Uuid'];
}>;
@ -564,11 +571,12 @@ export const GetRegistrationTypesDocument = {"kind":"Document","definitions":[{"
export const GetAddProductTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAddProductType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_addproduct_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"addproductTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_description"}}]}}]}}]} as unknown as DocumentNode<GetAddProductTypeQuery, GetAddProductTypeQueryVariables>;
export const GetQuoteBonusDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteBonusData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sale_bonus"}}]}}]}}]} as unknown as DocumentNode<GetQuoteBonusDataQuery, GetQuoteBonusDataQueryVariables>;
export const GetQuoteConfiguratorDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteConfiguratorData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}}]}}]}}]} as unknown as DocumentNode<GetQuoteConfiguratorDataQuery, GetQuoteConfiguratorDataQueryVariables>;
export const GetQuoteFingapDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteFingapData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_risks"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode<GetQuoteFingapDataQuery, GetQuoteFingapDataQueryVariables>;
export const GetQuoteFingapDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteFingapData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_risks"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode<GetQuoteFingapDataQuery, GetQuoteFingapDataQueryVariables>;
export const GetFinGapAddProductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetFinGAPAddProductTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000006"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","name":{"kind":"Name","value":"evo_type_calc_cerebellum"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_service_provider_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode<GetFinGapAddProductTypesQuery, GetFinGapAddProductTypesQueryVariables>;
export const GetQuoteGibddDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteGibddData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_db_accept_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_object_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_year"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_approved"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_registration_regionid"}}]}}]}}]} as unknown as DocumentNode<GetQuoteGibddDataQuery, GetQuoteGibddDataQueryVariables>;
export const GetQuoteRegionTownDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteRegionTown"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}}]}}]}}]} as unknown as DocumentNode<GetQuoteRegionTownQuery, GetQuoteRegionTownQueryVariables>;
export const GetInsuranceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInsuranceData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"osago"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_type_ins_policy"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000001"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","alias":{"kind":"Name","value":"kasko"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_type_ins_policy"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000000"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","alias":{"kind":"Name","value":"fingap"},"name":{"kind":"Name","value":"accounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_account_type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"evo_account_type"}}},{"kind":"Argument","name":{"kind":"Name","value":"evo_type_ins_policy"},"value":{"kind":"ListValue","values":[{"kind":"IntValue","value":"100000002"}]}},{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"accountid"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode<GetInsuranceDataQuery, GetInsuranceDataQueryVariables>;
export const GetQuoteInsuranceDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteInsuranceData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_osago_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_insurance_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_payer"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_period"}}]}}]}}]} as unknown as DocumentNode<GetQuoteInsuranceDataQuery, GetQuoteInsuranceDataQueryVariables>;
export const GetLeadUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeadUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"lead"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"leadid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode<GetLeadUrlQuery, GetLeadUrlQueryVariables>;
export const GetOpportunityUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOpportunityUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"opportunity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"opportunityid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode<GetOpportunityUrlQuery, GetOpportunityUrlQueryVariables>;
export const GetQuoteUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"entity"},"name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"link"}}]}}]}}]} as unknown as DocumentNode<GetQuoteUrlQuery, GetQuoteUrlQueryVariables>;

View File

@ -1,4 +1,4 @@
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import defaultValues from '@/config/default-values';
import * as CRMTypes from '@/graphql/crm.types';
@ -12,13 +12,9 @@ const QUERY_GET_QUOTE_BONUS_DATA = gql`
}
`;
type OutputData = {
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {

View File

@ -1,4 +1,4 @@
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import * as CRMTypes from '@/graphql/crm.types';
import { gql } from '@apollo/client';
@ -11,13 +11,9 @@ const QUERY_GET_QUOTE_CONFIGURATOR_DATA = gql`
}
`;
type OutputData = {
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {

View File

@ -1,18 +1,12 @@
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import { defaultValues } from '@/config/tables/insurance-table';
import * as CRMTypes from '@/graphql/crm.types';
import { gql } from '@apollo/client';
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const DEFAULT_FINGAP_ROW = defaultValues.find((x) => x.key === 'fingap')!;
const QUERY_GET_QUOTE_FINGAP_DATA = gql`
query GetQuoteFingapData($quoteId: Uuid!) {
quote(quoteId: $quoteId) {
evo_fingap_accountid
evo_fingap_payer
evo_fingap_period
evo_product_risks {
evo_addproduct_typeid
}
@ -20,16 +14,9 @@ const QUERY_GET_QUOTE_FINGAP_DATA = gql`
}
`;
type OutputData = {
fingap: GetQuoteOutputData['fingap'];
insurance: {
values: Pick<GetQuoteOutputData['insurance']['values'], 'fingap'>;
};
};
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {
@ -52,15 +39,5 @@ export async function getKPData({
fingap: {
keys,
},
insurance: {
values: {
fingap: {
...DEFAULT_FINGAP_ROW,
insTerm: quote?.evo_fingap_period || null,
insuranceCompany: quote?.evo_fingap_accountid || null,
insured: quote?.evo_fingap_payer || null,
},
},
},
};
}

View File

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import helper from './lib/helper';
import initializeApollo from '@/apollo/client';
import defaultValues from '@/config/default-values';
@ -29,11 +29,7 @@ const QUERY_GET_QUOTE_GIBDD_DATA = gql`
}
`;
type OutputData = {
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({ values }: GetQuoteInputData): Promise<OutputData> {
export async function getKPData({ values }: GetQuoteInputData): Promise<GetQuoteProcessData> {
const { quote: quoteId, recalcWithRevision, lead: leadId, opportunity: opportunityId } = values;
const apolloClient = initializeApollo();

View File

@ -0,0 +1,64 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import * as insuranceTable from '@/config/tables/insurance-table';
import * as CRMTypes from '@/graphql/crm.types';
import { gql } from '@apollo/client';
const { DEFAULT_FINGAP_ROW, DEFAULT_KASKO_ROW, DEFAULT_OSAGO_ROW } = insuranceTable;
const QUERY_GET_QUOTE_INSURANCE_DATA = gql`
query GetQuoteInsuranceData($quoteId: Uuid!) {
quote(quoteId: $quoteId) {
evo_osago_accountid
evo_osago_payer
evo_osago_price
evo_kasko_accountid
evo_kasko_payer
evo_kasko_price
evo_insurance_period
evo_fingap_accountid
evo_fingap_payer
evo_fingap_period
}
}
`;
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {
data: { quote },
} = await apolloClient.query({
query: CRMTypes.GetQuoteInsuranceDataDocument,
variables: {
quoteId,
},
});
return {
insurance: {
values: {
fingap: Object.assign(DEFAULT_FINGAP_ROW, {
insTerm: quote?.evo_fingap_period,
insuranceCompany: quote?.evo_fingap_accountid,
insured: quote?.evo_fingap_payer,
}),
kasko: Object.assign(DEFAULT_KASKO_ROW, {
insCost: quote?.evo_kasko_price,
insTerm: quote?.evo_insurance_period,
insuranceCompany: quote?.evo_kasko_accountid,
insured: quote?.evo_kasko_payer,
}),
osago: Object.assign(DEFAULT_OSAGO_ROW, {
insCost: quote?.evo_osago_price,
insTerm: quote?.evo_insurance_period,
insuranceCompany: quote?.evo_osago_accountid,
insured: quote?.evo_osago_payer,
}),
},
},
};
}

View File

@ -0,0 +1 @@
export * from './get-kp-data';

View File

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import defaultValues from '@/config/default-values';
import * as CRMTypes from '@/graphql/crm.types';
@ -33,13 +33,9 @@ const QUERY_GET_QUOTE_LEASING_OBJECT_DATA = gql`
}
`;
type OutputData = {
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({
values: { quote: quoteId, recalcWithRevision },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {

View File

@ -1,5 +1,4 @@
import type { ProcessContext } from '@/process/types';
import extend from '@/stores/tables/insurance/tools';
import { reaction } from 'mobx';
import message from 'ui/elements/message';
@ -48,13 +47,13 @@ export function common({ store, trpcClient }: ProcessContext) {
$tables.payments.setValues(payments.values);
if (insurance.values.osago) {
extend($tables.insurance).setRowValues(insurance.values.osago);
$tables.insurance.row('osago').setValues(insurance.values.osago);
}
if (insurance.values.kasko) {
extend($tables.insurance).setRowValues(insurance.values.kasko);
$tables.insurance.row('kasko').setValues(insurance.values.kasko);
}
if (insurance.values.fingap) {
extend($tables.insurance).setRowValues(insurance.values.fingap);
$tables.insurance.row('fingap').setValues(insurance.values.fingap);
}
if (fingap) $tables.fingap.setSelectedKeys(fingap.keys);

View File

@ -32,11 +32,21 @@ const InsuranceSchema = z.object({
export const GetQuoteOutputDataSchema = z
.object({
fingap: FinGAPSchema.optional(),
insurance: InsuranceSchema.required(),
fingap: FinGAPSchema,
insurance: InsuranceSchema,
payments: PaymentsSchema,
values: ValuesSchema,
})
.strict();
export type GetQuoteOutputData = z.infer<typeof GetQuoteOutputDataSchema>;
export const GetQuoteProcessDataSchema = GetQuoteOutputDataSchema.omit({
values: true,
})
.extend({
values: ValuesSchema.partial(),
})
.partial();
export type GetQuoteProcessData = z.infer<typeof GetQuoteProcessDataSchema>;

View File

@ -1,4 +1,4 @@
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import defaultValues from '@/config/default-values';
import * as CRMTypes from '@/graphql/crm.types';
@ -27,14 +27,9 @@ const QUERY_GET_QUOTE_PAYMENTS_DATA = gql`
}
`;
type OutputData = {
payments: GetQuoteOutputData['payments'];
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({
values: { quote: quoteId, recalcWithRevision },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {

View File

@ -1,4 +1,4 @@
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import defaultValues from '@/config/default-values';
import * as CRMTypes from '@/graphql/crm.types';
@ -23,13 +23,9 @@ const QUERY_GET_QUOTE_PRICE_DATA = gql`
}
`;
type OutputData = {
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {

View File

@ -1,4 +1,4 @@
import type { GetQuoteInputData, GetQuoteOutputData } from '../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
import initializeApollo from '@/apollo/client';
import defaultValues from '@/config/default-values';
import * as CRMTypes from '@/graphql/crm.types';
@ -13,13 +13,9 @@ const QUERY_GET_QUOTE_SUBSIDY_DATA = gql`
}
`;
type OutputData = {
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {

View File

@ -1,5 +1,5 @@
/* eslint-disable canonical/sort-keys */
import type { GetQuoteInputData, GetQuoteOutputData } from '../../load-kp/types';
import type { GetQuoteInputData, GetQuoteProcessData } from '../../load-kp/types';
import getSums from './get-sums';
import initializeApollo from '@/apollo/client';
import defaultValues from '@/config/default-values';
@ -38,13 +38,9 @@ const QUERY_GET_QUOTE_AGENTS_DATA = gql`
}
`;
type OutputData = {
values: Partial<GetQuoteOutputData['values']>;
};
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<OutputData> {
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {

View File

@ -118,6 +118,12 @@ export default class InsuranceTable {
return this.row(key);
},
setValues: (row: Insurance.RowValues) => {
(Object.keys(row) as Insurance.Values[]).forEach((valueName) => {
this.row(row.key).setValue(valueName, row[valueName]);
});
},
unblock: (valueName: Insurance.Values) => {
this.statuses[key][valueName] = 'Default';

View File

@ -1,12 +0,0 @@
import type InsuranceTable from '.';
import type * as Insurance from '@/Components/Calculation/Form/Insurance/InsuranceTable/types';
export default function extend(insuranceTable: InsuranceTable) {
return {
setRowValues(row: Insurance.RowValues) {
(Object.keys(row) as Insurance.Values[]).forEach((valueName) => {
insuranceTable.row(row.key).setValue(valueName, row[valueName]);
});
},
};
}

View File

@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable canonical/sort-keys */
import { t } from '../server';
import defaultValues from '@/config/default-values';
import { defaultValues as defaultInsuranceValues } from '@/config/tables/insurance-table';
import * as insuranceTable from '@/config/tables/insurance-table';
import * as bonuses from '@/process/bonuses';
import * as configurator from '@/process/configurator';
import * as fingapProcess from '@/process/fingap';
import * as gibdd from '@/process/gibdd';
import * as insuranceProcess from '@/process/insurance';
import * as leasingObject from '@/process/leasing-object';
import * as loadKP from '@/process/load-kp';
import * as paymentsProcess from '@/process/payments';
@ -13,49 +15,49 @@ import * as price from '@/process/price';
import * as subsidy from '@/process/subsidy';
import * as supplierAgent from '@/process/supplier-agent';
const DEFAULT_OSAGO_ROW = defaultInsuranceValues.find((x) => x.key === 'osago');
const DEFAULT_KASKO_ROW = defaultInsuranceValues.find((x) => x.key === 'kasko');
const { GetQuoteInputDataSchema, GetQuoteOutputDataSchema } = loadKP;
const { DEFAULT_FINGAP_ROW, DEFAULT_KASKO_ROW, DEFAULT_OSAGO_ROW } = insuranceTable;
const {
GetQuoteInputDataSchema: GetQuoteDataInputSchema,
GetQuoteOutputDataSchema: GetQuoteDataOutputSchema,
} = loadKP;
const defaultInsurance = {
values: {
fingap: DEFAULT_FINGAP_ROW,
kasko: DEFAULT_KASKO_ROW,
osago: DEFAULT_OSAGO_ROW,
},
};
const defaultFingap = { keys: [] };
const defaultPayments = { values: [] };
const quoteRouter = t.router({
getData: t.procedure
.input(GetQuoteDataInputSchema)
.output(GetQuoteDataOutputSchema)
.input(GetQuoteInputDataSchema)
.output(GetQuoteOutputDataSchema)
.query(async ({ input }) => {
const { values: configuratorValues } = await configurator.getKPData(input);
const { values: supplierAgentsValues } = await supplierAgent.getKPData(input);
const { values: paymentsValues, payments } = await paymentsProcess.getKPData(input);
const { values: priceValues } = await price.getKPData(input);
const { values: bonusesValues } = await bonuses.getKPData(input);
const { values: leasingObjectValues } = await leasingObject.getKPData(input);
const { fingap, insurance: fingapInsurance } = await fingapProcess.getKPData(input);
const { values: gibddValues } = await gibdd.getKPData(input);
const { values: subsidyValues } = await subsidy.getKPData(input);
const output = await Promise.all(
[
configurator,
supplierAgent,
paymentsProcess,
price,
bonuses,
leasingObject,
fingapProcess,
gibdd,
subsidy,
insuranceProcess,
].map(({ getKPData }) => getKPData(input))
);
const values = output.reduce((obj, data) => Object.assign(obj, data.values), defaultValues);
const payments = output.find((x) => x.payments)?.payments ?? defaultPayments;
const insurance = output.find((x) => x.insurance)?.insurance ?? defaultInsurance;
const fingap = output.find((x) => x.fingap)?.fingap ?? defaultFingap;
return {
values: {
...defaultValues,
...configuratorValues,
...supplierAgentsValues,
...paymentsValues,
...priceValues,
...bonusesValues,
...leasingObjectValues,
...gibddValues,
...subsidyValues,
},
values,
payments,
insurance: {
values: {
osago: DEFAULT_OSAGO_ROW,
kasko: DEFAULT_KASKO_ROW,
fingap: fingapInsurance.values.fingap,
},
},
insurance,
fingap,
};
}),