50 lines
2.0 KiB
TypeScript
50 lines
2.0 KiB
TypeScript
import defaultValues from 'config/default-values';
|
|
import { defaultValues as defaultInsuranceValues } from 'config/tables/insurance-table';
|
|
import getConfiguratorDataFromKP from 'process/configurator/get-kp-data';
|
|
import getFingapDataFromKP from 'process/fingap/get-kp-data';
|
|
import getLeasingObjectDataFromKP from 'process/leasing-object/get-kp-data';
|
|
import { GetQuoteDataInputSchema, GetQuoteDataOutputSchema } from 'process/load-kp/types';
|
|
import getPaymentsDataFromKP from 'process/payments/get-kp-data';
|
|
import getPriceDataFromKP from 'process/price/get-kp-data';
|
|
import getSupplierAgentsDataFromKP from 'process/supplier-agent/get-kp-values';
|
|
import { t } from '../server';
|
|
|
|
const DEFAULT_OSAGO_ROW = defaultInsuranceValues.find((x) => x.key === 'osago');
|
|
const DEFAULT_KASKO_ROW = defaultInsuranceValues.find((x) => x.key === 'kasko');
|
|
|
|
const quoteRouter = t.router({
|
|
getData: t.procedure
|
|
.input(GetQuoteDataInputSchema)
|
|
.output(GetQuoteDataOutputSchema)
|
|
.query(async ({ input }) => {
|
|
const { values: configuratorValues } = await getConfiguratorDataFromKP(input);
|
|
const { values: supplierAgentsValues } = await getSupplierAgentsDataFromKP(input);
|
|
const { values: paymentsValues, payments } = await getPaymentsDataFromKP(input);
|
|
const { values: priceValues } = await getPriceDataFromKP(input);
|
|
const { values: leasingObjectValues } = await getLeasingObjectDataFromKP(input);
|
|
const { fingap, insurance: fingapInsurance } = await getFingapDataFromKP(input);
|
|
|
|
return {
|
|
values: {
|
|
...defaultValues,
|
|
...configuratorValues,
|
|
...supplierAgentsValues,
|
|
...paymentsValues,
|
|
...priceValues,
|
|
...leasingObjectValues,
|
|
},
|
|
payments,
|
|
insurance: {
|
|
values: {
|
|
osago: DEFAULT_OSAGO_ROW,
|
|
kasko: DEFAULT_KASKO_ROW,
|
|
fingap: fingapInsurance.values.fingap,
|
|
},
|
|
},
|
|
fingap,
|
|
};
|
|
}),
|
|
});
|
|
|
|
export default quoteRouter;
|