2025-11-13 15:45:55 +01:00
|
|
|
import z from "zod";
|
|
|
|
|
import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";
|
|
|
|
|
import {
|
|
|
|
|
getComuneById,
|
|
|
|
|
getComuni,
|
|
|
|
|
getNazioneById,
|
|
|
|
|
getNazioni,
|
|
|
|
|
getProvincie,
|
2025-11-20 16:48:29 +01:00
|
|
|
searchComuniByCatasto,
|
2025-11-13 15:45:55 +01:00
|
|
|
} from "~/server/controllers/catasto.controller";
|
|
|
|
|
|
|
|
|
|
import { zComuneId, zNazioneId } from "~/server/utils/zod_types";
|
|
|
|
|
|
|
|
|
|
export const catastoRouter = createTRPCRouter({
|
|
|
|
|
getComuni: publicProcedure.query(async () => {
|
|
|
|
|
return await getComuni();
|
|
|
|
|
}),
|
2025-11-20 16:48:29 +01:00
|
|
|
searchComuniByCatasto: publicProcedure
|
|
|
|
|
.input(
|
|
|
|
|
z.object({
|
|
|
|
|
catasto: z.string().array(),
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
|
return await searchComuniByCatasto(input.catasto);
|
|
|
|
|
}),
|
2025-11-13 15:45:55 +01:00
|
|
|
getComuneById: publicProcedure
|
|
|
|
|
.input(
|
|
|
|
|
z.object({
|
|
|
|
|
id: zComuneId,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
|
return await getComuneById(input.id);
|
|
|
|
|
}),
|
|
|
|
|
getProvincie: publicProcedure.query(async () => {
|
|
|
|
|
return await getProvincie();
|
|
|
|
|
}),
|
|
|
|
|
getNazioni: publicProcedure.query(async () => {
|
|
|
|
|
return await getNazioni();
|
|
|
|
|
}),
|
|
|
|
|
getNazioneById: publicProcedure
|
|
|
|
|
.input(
|
|
|
|
|
z.object({
|
|
|
|
|
id: zNazioneId,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
|
return await getNazioneById(input.id);
|
|
|
|
|
}),
|
|
|
|
|
});
|