infoalloggi-monorepo/apps/infoalloggi/src/server/api/routers/fatture.ts

49 lines
981 B
TypeScript
Raw Normal View History

import { z } from "zod/v4";
2025-08-04 17:45:44 +02:00
import {
2025-08-28 18:27:07 +02:00
adminProcedure,
createTRPCRouter,
protectedProcedure,
publicProcedure,
2025-08-04 17:45:44 +02:00
} from "~/server/api/trpc";
import {
2025-08-28 18:27:07 +02:00
addClient,
getClientFromCF,
getClientList,
searchClient,
2025-08-04 17:45:44 +02:00
} from "~/server/controllers/fic.controller";
import { ClientSchema } from "~/server/services/fic.service";
export const fattureRouter = createTRPCRouter({
2025-08-29 16:18:32 +02:00
createClient: protectedProcedure
2025-08-28 18:27:07 +02:00
.input(
z.object({
2025-08-29 16:18:32 +02:00
client: ClientSchema,
2025-08-28 18:27:07 +02:00
}),
)
2025-08-29 16:18:32 +02:00
.mutation(async ({ input }) => {
return await addClient(input.client);
2025-08-28 18:27:07 +02:00
}),
getClientFromCF: publicProcedure
.input(
z.object({
cf: z.string(),
}),
)
.query(async ({ input }) => {
return await getClientFromCF(input.cf);
}),
2025-08-29 16:18:32 +02:00
getListClienti: adminProcedure.query(async () => {
return await getClientList();
}),
searchClient: adminProcedure
2025-08-28 18:27:07 +02:00
.input(
z.object({
2025-08-29 16:18:32 +02:00
cognome: z.string(),
2025-08-28 18:27:07 +02:00
}),
)
2025-08-29 16:18:32 +02:00
.query(async ({ input }) => {
return await searchClient(input.cognome);
2025-08-28 18:27:07 +02:00
}),
2025-08-04 17:45:44 +02:00
});