60 lines
2.1 KiB
TypeScript

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';
import { gql } from '@apollo/client';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const QUERY_GET_CREATEKP_DATA = gql`
query GetQuoteCreateKPData($quoteId: Uuid!) {
quote(quoteId: $quoteId) {
evo_price_with_discount
evo_price_without_discount_quote
evo_cost_increace
evo_insurance
evo_registration_quote
evo_card_quote
evo_nsib_quote
evo_redemption_graph
evo_fingap_quote
evo_contact_name
evo_gender
evo_last_payment_redemption
}
}
`;
export async function getKPData({
values: { quote: quoteId },
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
const apolloClient = initializeApollo();
const {
data: { quote },
} = await apolloClient.query({
query: CRMTypes.GetQuoteCreateKpDataDocument,
variables: {
quoteId,
},
});
return {
values: {
NSIB: quote?.evo_nsib_quote ?? defaultValues.NSIB,
costIncrease: quote?.evo_cost_increace ?? defaultValues.costIncrease,
fullPriceWithDiscount:
quote?.evo_price_without_discount_quote ?? defaultValues.fullPriceWithDiscount,
insurance: quote?.evo_insurance ?? defaultValues.insurance,
lastPaymentRedemption:
quote?.evo_last_payment_redemption ?? defaultValues.lastPaymentRedemption,
priceWithDiscount: quote?.evo_price_with_discount ?? defaultValues.priceWithDiscount,
quoteContactGender: quote?.evo_gender ?? defaultValues.quoteContactGender,
quoteName: quote?.evo_contact_name ?? defaultValues.quoteName,
quoteRedemptionGraph: quote?.evo_redemption_graph ?? defaultValues.quoteRedemptionGraph,
registrationQuote: quote?.evo_registration_quote ?? defaultValues.registrationQuote,
showFinGAP: quote?.evo_fingap_quote ?? defaultValues.showFinGAP,
technicalCardQuote: quote?.evo_card_quote ?? defaultValues.technicalCardQuote,
},
};
}