import z from "zod";
import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";
import {
	getComuni,
	getNazioni,
	getProvincie,
	searchComuniByCatasto,
} from "~/server/controllers/catasto.controller";

export const catastoRouter = createTRPCRouter({
	getComuni: publicProcedure.query(async () => {
		return await getComuni();
	}),
	searchComuniByCatasto: publicProcedure
		.input(
			z.object({
				catasto: z.string().array(),
			}),
		)
		.query(async ({ input }) => {
			return await searchComuniByCatasto(input.catasto);
		}),

	getProvincie: publicProcedure.query(async () => {
		return await getProvincie();
	}),
	getNazioni: publicProcedure.query(async () => {
		return await getNazioni();
	}),
});
