diff --git a/process/fingap/get-kp-data.ts b/process/fingap/get-kp-data.ts index 34ab45c..8ed68d0 100644 --- a/process/fingap/get-kp-data.ts +++ b/process/fingap/get-kp-data.ts @@ -1,11 +1,8 @@ import { gql } from '@apollo/client'; import initializeApollo from 'apollo/client'; -import { RowSchema } from 'config/schema/insurance'; import { defaultValues } from 'config/tables/insurance-table'; import type * as CRMTypes from 'graphql/crm.types'; -import { z } from 'zod'; -import type { GetQuoteDataInput } from '../load-kp/types'; -import { GetQuoteDataOutputSchema } from '../load-kp/types'; +import type { GetQuoteDataInput, GetQuoteDataOutput } from '../load-kp/types'; const DEFAULT_FINGAP_ROW = defaultValues.find((x) => x.key === 'fingap')!; @@ -22,16 +19,12 @@ const QUERY_GET_RISKS = gql` } `; -const QuoteFingapProcessDataSchema = z.object({ - insurance: z.object({ - values: z.object({ - fingap: RowSchema, - }), - }), - fingap: GetQuoteDataOutputSchema.shape.fingap, -}); - -type QuoteFingapProcessData = z.infer; +type QuoteFingapProcessData = { + insurance: { + values: Pick; + }; + fingap: GetQuoteDataOutput['fingap']; +}; export default async function getFingapDataFromKP({ values: { quote: quoteId }, @@ -50,18 +43,16 @@ export default async function getFingapDataFromKP({ }, }); - const values: Array<{ key: string }> = []; + const keys: Array = []; quote?.evo_product_risks?.forEach((x) => { if (x.evo_addproduct_typeid) { - values.push({ - key: x.evo_addproduct_typeid, - }); + keys.push(x.evo_addproduct_typeid); } }); return { fingap: { - values, + keys, }, insurance: { values: { diff --git a/process/load-kp/reactions.ts b/process/load-kp/reactions.ts index 8a2146d..3e7db13 100644 --- a/process/load-kp/reactions.ts +++ b/process/load-kp/reactions.ts @@ -50,7 +50,7 @@ export default function loadKpReactions({ store, trpcClient }: ReactionsContext) extend($tables.insurance).setRowValues(insurance.values.fingap); } - if (fingap) $tables.fingap.setSelectedKeys(fingap.values?.map((x) => x.key)); + if (fingap) $tables.fingap.setSelectedKeys(fingap.keys); message.success({ key, diff --git a/process/load-kp/types.ts b/process/load-kp/types.ts index 2254cbf..4f9778c 100644 --- a/process/load-kp/types.ts +++ b/process/load-kp/types.ts @@ -25,11 +25,7 @@ export const GetQuoteDataOutputSchema = z.object({ .required(), fingap: z .object({ - values: z.array( - RiskSchema.pick({ - key: true, - }) - ), + keys: z.array(RiskSchema.shape.key), }) .optional(), }); diff --git a/process/payments/get-kp-data.ts b/process/payments/get-kp-data.ts index 03ff82e..a998ada 100644 --- a/process/payments/get-kp-data.ts +++ b/process/payments/get-kp-data.ts @@ -3,9 +3,7 @@ import { gql } from '@apollo/client'; import initializeApollo from 'apollo/client'; import type * as CRMTypes from 'graphql/crm.types'; import { sort } from 'radash'; -import { z } from 'zod'; -import type { GetQuoteDataInput } from '../load-kp/types'; -import { GetQuoteDataOutputSchema } from '../load-kp/types'; +import type { GetQuoteDataInput, GetQuoteDataOutput } from '../load-kp/types'; const QUERY_GET_PAYMENTS_DATA_FROM_QUOTE = gql` query GetPaymentsDataFromQuote($quoteId: Uuid!) { @@ -29,12 +27,10 @@ const QUERY_GET_PAYMENTS_DATA_FROM_QUOTE = gql` } `; -const { values, payments } = GetQuoteDataOutputSchema.shape; -const QuotePaymentsProcessDataSchema = z.object({ - values: values.partial(), - payments, -}); -type QuotePaymentsProcessData = z.infer; +type QuotePaymentsProcessData = { + values: Partial; + payments: GetQuoteDataOutput['payments']; +}; export default async function getPaymentsDataFromKP({ values: { quote: quoteId, recalcWithRevision }, diff --git a/process/supplier-agent/get-kp-values/index.ts b/process/supplier-agent/get-kp-values/index.ts index a6dea03..9429a3a 100644 --- a/process/supplier-agent/get-kp-values/index.ts +++ b/process/supplier-agent/get-kp-values/index.ts @@ -1,9 +1,7 @@ import { gql } from '@apollo/client'; import initializeApollo from 'apollo/client'; import type * as CRMTypes from 'graphql/crm.types'; -import { z } from 'zod'; -import type { GetQuoteDataInput } from '../../load-kp/types'; -import { GetQuoteDataOutputSchema } from '../../load-kp/types'; +import type { GetQuoteDataInput, GetQuoteDataOutput } from '../../load-kp/types'; import getSums from './get-sums'; const QUERY_GET_AGENTS_DATA_FROM_QUOTE = gql` @@ -39,10 +37,10 @@ const QUERY_GET_AGENTS_DATA_FROM_QUOTE = gql` `; export type Quote = NonNullable; -const QuoteSupplierAgentProcessDataSchema = z.object({ - values: GetQuoteDataOutputSchema.shape.values.partial(), -}); -type QuoteSupplierAgentProcessData = z.infer; + +type QuoteSupplierAgentProcessData = { + values: Partial; +}; export default async function getSupplierAgentsDataFromKP({ values: { quote: quoteId },