85 lines
2.8 KiB
TypeScript
85 lines
2.8 KiB
TypeScript
/* 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/default-values';
|
|
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;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
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
|
|
evo_fingap_price
|
|
evo_gps_brandid
|
|
evo_gps_modelid
|
|
evo_insurance_decentral
|
|
evo_franchise
|
|
evo_unlimit_drivers
|
|
evo_age_drivers
|
|
evo_exp_drivers
|
|
}
|
|
}
|
|
`;
|
|
|
|
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, {
|
|
insCost: quote?.evo_fingap_price ?? DEFAULT_FINGAP_ROW.insCost,
|
|
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 ?? DEFAULT_KASKO_ROW.insCost,
|
|
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 ?? DEFAULT_OSAGO_ROW.insCost,
|
|
insTerm: quote?.evo_insurance_period,
|
|
insuranceCompany: quote?.evo_osago_accountid,
|
|
insured: quote?.evo_osago_payer,
|
|
}),
|
|
},
|
|
},
|
|
values: {
|
|
GPSBrand: quote?.evo_gps_brandid,
|
|
GPSModel: quote?.evo_gps_modelid,
|
|
insAgeDrivers: quote?.evo_age_drivers ?? defaultValues.insAgeDrivers,
|
|
insDecentral: quote?.evo_insurance_decentral ?? defaultValues.insDecentral,
|
|
insExpDrivers: quote?.evo_exp_drivers ?? defaultValues.insExpDrivers,
|
|
insFranchise: quote?.evo_franchise ?? defaultValues.insFranchise,
|
|
insUnlimitDrivers: quote?.evo_unlimit_drivers ?? defaultValues.insUnlimitDrivers,
|
|
},
|
|
};
|
|
}
|