create-kp: temp fix pass fingap row
This commit is contained in:
parent
2029397158
commit
653b154f2a
@ -21,7 +21,7 @@ export const RequestCreateKPSchema = z.object({
|
||||
),
|
||||
domainName: z.string(),
|
||||
finGAP: RiskSchema.array(),
|
||||
insurance: RowSchema.array(),
|
||||
insurance: RowSchema.extend({ key: z.string() }).array(),
|
||||
});
|
||||
|
||||
export type RequestCreateKP = z.infer<typeof RequestCreateKPSchema>;
|
||||
|
||||
@ -13,6 +13,7 @@ import {
|
||||
} from './types';
|
||||
import { calculate } from '@/api/core/query';
|
||||
import { createKP } from '@/api/crm/query';
|
||||
import type { RequestCreateKP } from '@/api/crm/types';
|
||||
import type { User } from '@/api/user/types';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import defaultValues from '@/config/default-values';
|
||||
@ -133,7 +134,7 @@ export const quoteRouter = router({
|
||||
};
|
||||
}
|
||||
|
||||
const createKPResult = await createKP({
|
||||
const requestCreateKP = compatRequestCreateKP({
|
||||
domainName: user.domainName,
|
||||
finGAP: input.fingap,
|
||||
insurance: Object.values(input.insurance.values),
|
||||
@ -145,6 +146,8 @@ export const quoteRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
const createKPResult = await createKP(requestCreateKP);
|
||||
|
||||
if (createKPResult.success === false) {
|
||||
return {
|
||||
success: false,
|
||||
@ -171,6 +174,15 @@ export const quoteRouter = router({
|
||||
}),
|
||||
});
|
||||
|
||||
function compatRequestCreateKP(request: RequestCreateKP) {
|
||||
const fingapIndex = request.insurance.findIndex((x) => x.key === 'fingap');
|
||||
if (fingapIndex >= 0) {
|
||||
request.insurance[fingapIndex].key = 'finGAP';
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
async function compatValues(
|
||||
values: CalculationValues,
|
||||
{ apolloClient }: Pick<Context, 'apolloClient'>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user