44 lines
1010 B
TypeScript
44 lines
1010 B
TypeScript
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
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';
|
|
|
|
const QUERY_GET_QUOTE_FINGAP_DATA = gql`
|
|
query GetQuoteFingapData($quoteId: Uuid!) {
|
|
quote(quoteId: $quoteId) {
|
|
evo_product_risks {
|
|
evo_addproduct_typeid
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export async function getKPData({
|
|
values: { quote: quoteId },
|
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
|
const apolloClient = initializeApollo();
|
|
|
|
const {
|
|
data: { quote },
|
|
} = await apolloClient.query({
|
|
query: CRMTypes.GetQuoteFingapDataDocument,
|
|
variables: {
|
|
quoteId,
|
|
},
|
|
});
|
|
|
|
const keys: string[] = [];
|
|
quote?.evo_product_risks?.forEach((x) => {
|
|
if (x?.evo_addproduct_typeid) {
|
|
keys.push(x.evo_addproduct_typeid);
|
|
}
|
|
});
|
|
|
|
return {
|
|
fingap: {
|
|
keys,
|
|
},
|
|
};
|
|
}
|