get calculation values types from zod schema add loadKP reaction get base agents data from kp
40 lines
911 B
TypeScript
40 lines
911 B
TypeScript
import defaultValues from 'config/default-values';
|
|
import ValuesSchema from 'config/schema/values';
|
|
import getSupplierAgentsDataFromKP from 'process/supplier-agent/get-data-from-kp';
|
|
import { z } from 'zod';
|
|
import { t } from '../server';
|
|
|
|
const quoteRouter = t.router({
|
|
getValues: t.procedure
|
|
.input(
|
|
z.object({
|
|
values: ValuesSchema,
|
|
})
|
|
)
|
|
.output(
|
|
z.object({
|
|
values: ValuesSchema,
|
|
})
|
|
)
|
|
.query(async ({ input }) => {
|
|
const { values } = await getSupplierAgentsDataFromKP(input.values);
|
|
|
|
const { lead, opportunity, quote, leadUrl, opportunityUrl, quoteUrl } = input.values;
|
|
|
|
return {
|
|
values: {
|
|
...defaultValues,
|
|
lead,
|
|
leadUrl,
|
|
opportunity,
|
|
opportunityUrl,
|
|
quote,
|
|
quoteUrl,
|
|
...values,
|
|
},
|
|
};
|
|
}),
|
|
});
|
|
|
|
export default quoteRouter;
|