20 lines
677 B
TypeScript
20 lines
677 B
TypeScript
import { protectedProcedure } from '../../procedure';
|
|
import { router } from '../../trpc';
|
|
import { GetTarifInputSchema } from './types';
|
|
import initializeApollo from '@/apollo/client';
|
|
import configuratorHelper from '@/process/configurator/lib/helper';
|
|
import { createTRPCError } from '@/utils/trpc';
|
|
|
|
export const tarifRouter = router({
|
|
getTarif: protectedProcedure.input(GetTarifInputSchema).query(async ({ input, ctx }) => {
|
|
try {
|
|
const apolloClient = initializeApollo(null, ctx.headers);
|
|
const { getTarifs } = configuratorHelper({ apolloClient });
|
|
|
|
return getTarifs(input);
|
|
} catch (error) {
|
|
throw createTRPCError(error);
|
|
}
|
|
}),
|
|
});
|