- Replaced references to `api.settings` with `api.etichette`, `api.flags`, and `api.strings` in various admin pages to align with new API structure. - Removed the deprecated `settingsRouter` and introduced `flagsRouter`, `etichetteRouter`, and `stringsRouter` to handle respective functionalities. - Updated the `Flags` schema to change the `value` field from string to boolean. - Modified flag handling logic in the `SendMessage` and `NewMail` functions to check for boolean flags instead of string values. - Added migration script to convert the `value` column in the `flags` table from string to boolean. - Implemented new routers for banners, etichette, flags, revalidation, and strings to encapsulate related functionalities.
78 lines
1.7 KiB
TypeScript
78 lines
1.7 KiB
TypeScript
import { z } from "zod/v4";
|
|
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";
|
|
import { zTestiEStringheStingaId } from "~/server/utils/zod_types";
|
|
|
|
export const stringsRouter = createTRPCRouter({
|
|
getStringa: publicProcedure
|
|
.input(
|
|
z.object({
|
|
stringaId: zTestiEStringheStingaId,
|
|
}),
|
|
)
|
|
.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: zTestiEStringheStingaId,
|
|
}),
|
|
)
|
|
.mutation(async ({ input }) => {
|
|
return await deleteStringa({
|
|
db,
|
|
stringaId: input.stringaId,
|
|
});
|
|
}),
|
|
newStringa: adminProcedure
|
|
.input(
|
|
z.object({
|
|
stringaId: zTestiEStringheStingaId,
|
|
stringaValue: z.string().nullable(),
|
|
}),
|
|
)
|
|
.mutation(async ({ input }) => {
|
|
return await newStringa({
|
|
db,
|
|
stringaId: input.stringaId,
|
|
stringaValue: input.stringaValue,
|
|
});
|
|
}),
|
|
|
|
updateStringa: adminProcedure
|
|
.input(
|
|
z.object({
|
|
stringaId: zTestiEStringheStingaId,
|
|
stringaValue: z.string().nullable(),
|
|
}),
|
|
)
|
|
.mutation(async ({ input }) => {
|
|
return await updateStringhe({
|
|
db,
|
|
stringaId: input.stringaId,
|
|
stringaValue: input.stringaValue,
|
|
});
|
|
}),
|
|
});
|