create-kp: pass elt data
This commit is contained in:
parent
654cd58c45
commit
843b8b5b16
@ -17,7 +17,7 @@ const storeSelector: StoreSelector = ({ kasko }) => kasko;
|
||||
|
||||
export function Kasko() {
|
||||
const store = useStore();
|
||||
const { $tables } = store;
|
||||
const { $tables, $calculation } = store;
|
||||
const rows = $tables.elt.kasko.getRows;
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
@ -51,7 +51,7 @@ export function Kasko() {
|
||||
refetch()
|
||||
.then((res) => {
|
||||
if (res.data) {
|
||||
const { key, kaskoSum, message, skCalcId, totalFranchise } = res.data;
|
||||
const { key, kaskoSum, message, skCalcId, totalFranchise, requestId } = res.data;
|
||||
let { error } = res.data;
|
||||
|
||||
if (totalFranchise > MAX_FRANCHISE) {
|
||||
@ -88,6 +88,7 @@ export function Kasko() {
|
||||
key,
|
||||
message: error || message,
|
||||
numCalc: 0,
|
||||
requestId,
|
||||
skCalcId,
|
||||
status: error ? 'error' : null,
|
||||
sum: kaskoSum,
|
||||
@ -101,6 +102,8 @@ export function Kasko() {
|
||||
key: data?.key,
|
||||
message: error,
|
||||
numCalc: 0,
|
||||
requestId: '',
|
||||
skCalcId: '',
|
||||
status: 'error',
|
||||
sum: 0,
|
||||
totalFranchise: 0,
|
||||
@ -112,6 +115,7 @@ export function Kasko() {
|
||||
function handleOnSelectRow(row: Row) {
|
||||
$tables.insurance.row('kasko').column('insuranceCompany').setValue(row.key);
|
||||
$tables.insurance.row('kasko').column('insCost').setValue(row.sum);
|
||||
$calculation.element('tbxInsFranchise').setValue(row.totalFranchise);
|
||||
}
|
||||
|
||||
const kaskoColumns = clone(columns);
|
||||
|
||||
@ -90,6 +90,7 @@ export function Osago() {
|
||||
key: data?.key,
|
||||
message: error,
|
||||
numCalc: 0,
|
||||
skCalcId: '',
|
||||
status: 'error',
|
||||
sum: 0,
|
||||
});
|
||||
|
||||
@ -439,7 +439,7 @@ export async function makeEltKaskoRequest(
|
||||
outsideRoadsSpecified = true;
|
||||
}
|
||||
|
||||
const franchise = $calculation.element('tbxInsFranchise').getValue();
|
||||
const franchise = row.totalFranchise;
|
||||
const franchiseSpecified = getSpecified(franchise);
|
||||
|
||||
let puuMark = '';
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { RequestCalculateSchema, ResponseCalculateSchema } from '../core/types';
|
||||
import { RowSchema as EltRowSchema } from '@/config/schema/elt';
|
||||
import { RiskSchema } from '@/config/schema/fingap';
|
||||
import { RowSchema } from '@/config/schema/insurance';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
@ -20,6 +21,10 @@ export const RequestCreateKPSchema = z.object({
|
||||
})
|
||||
),
|
||||
domainName: z.string(),
|
||||
elt: z.object({
|
||||
kasko: EltRowSchema.optional(),
|
||||
osago: EltRowSchema.optional(),
|
||||
}),
|
||||
finGAP: RiskSchema.array(),
|
||||
insurance: RowSchema.extend({ key: z.string() }).array(),
|
||||
});
|
||||
|
||||
@ -28,8 +28,14 @@ export function action({ store, trpcClient, apolloClient }: ProcessContext) {
|
||||
const paymentRelations = toJS($tables.payments.values);
|
||||
const paymentSums = toJS($tables.payments.sums);
|
||||
|
||||
const elt = {
|
||||
kasko: toJS($tables.elt.kasko.getSelectedRow),
|
||||
osago: toJS($tables.elt.osago.getSelectedRow),
|
||||
};
|
||||
|
||||
trpcClient.createQuote
|
||||
.mutate({
|
||||
elt,
|
||||
fingap,
|
||||
insurance: { values: insurance },
|
||||
payments: { sums: paymentSums, values: paymentRelations },
|
||||
|
||||
@ -148,6 +148,7 @@ export const quoteRouter = router({
|
||||
preparedPayments: requestData.preparedPayments,
|
||||
additionalData: requestData.additionalData,
|
||||
},
|
||||
elt: input.elt,
|
||||
});
|
||||
|
||||
const createKPResult = await createKP(requestCreateKP);
|
||||
|
||||
@ -70,6 +70,10 @@ export const GetQuoteProcessDataSchema = GetQuoteOutputDataSchema.omit({
|
||||
export type GetQuoteProcessData = z.infer<typeof GetQuoteProcessDataSchema>;
|
||||
|
||||
export const CreateQuoteInputDataSchema = CalculateInputSchema.extend({
|
||||
elt: z.object({
|
||||
kasko: EltRowSchema.optional(),
|
||||
osago: EltRowSchema.optional(),
|
||||
}),
|
||||
fingap: RiskSchema.array(),
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user