infoalloggi-monorepo/apps/infoalloggi/src/server/api/routers/strings.ts
Marco Pedone 60e4b187bf Refactor: Update Zod schemas and replace custom types with imported schemas across various files
- Replaced custom Zod types with imported schemas in stripe router and user router.
- Updated payment controller to use new enum imports for order types and payment statuses.
- Refactored payment tests to utilize the new enum structure.
- Removed deprecated zod_types file and created new zod_chat_types file for chat-related schemas.
- Adjusted service files to align with the new order type enums and schemas.
- Enhanced the Caratteristiche type definition using Zod for better validation.

Co-authored-by: Copilot <copilot@github.com>
2026-04-28 20:32:19 +02:00

78 lines
1.7 KiB
TypeScript

import { z } from "zod/v4";
import { testiEStringheStingaId } from "~/schemas/public/TestiEStringhe";
import {
adminProcedure,
createTRPCRouter,
publicProcedure,
} from "~/server/api/trpc";
import { db } from "~/server/db";
import {
deleteStringa,
getStringa,
getStringhe,
getStringheFiltered,
newStringa,
updateStringhe,
} from "~/server/services/testi_stringhe.service";
export const stringsRouter = createTRPCRouter({
getStringa: publicProcedure
.input(
z.object({
stringaId: testiEStringheStingaId,
}),
)
.query(async ({ input }) => {
return await getStringa({
db,
stringaId: input.stringaId,
});
}),
getStringhe: adminProcedure.query(async () => {
return await getStringhe({ db });
}),
getStringheCondizioni: adminProcedure.query(async () => {
return await getStringheFiltered({ contains: "CONDIZIONI", db });
}),
deleteStringa: adminProcedure
.input(
z.object({
stringaId: testiEStringheStingaId,
}),
)
.mutation(async ({ input }) => {
return await deleteStringa({
db,
stringaId: input.stringaId,
});
}),
newStringa: adminProcedure
.input(
z.object({
stringaId: testiEStringheStingaId,
stringaValue: z.string().nullable(),
}),
)
.mutation(async ({ input }) => {
return await newStringa({
db,
stringaId: input.stringaId,
stringaValue: input.stringaValue,
});
}),
updateStringa: adminProcedure
.input(
z.object({
stringaId: testiEStringheStingaId,
stringaValue: z.string().nullable(),
}),
)
.mutation(async ({ input }) => {
return await updateStringhe({
db,
stringaId: input.stringaId,
stringaValue: input.stringaValue,
});
}),
});