create category dialog

This commit is contained in:
2025-03-08 12:48:18 +01:00
parent dd3c321350
commit 66aadfd04d
19 changed files with 535 additions and 25 deletions
+5 -1
View File
@@ -6,7 +6,7 @@ import {
} from "@/server/api/trpc";
import { categories } from "@/server/db/schema";
import { eq } from "drizzle-orm";
import { count, eq } from "drizzle-orm";
import { hasPermission, Role } from "@/lib/validation/permissions";
import { categorySchema } from "@/lib/validation/zod/category";
import { generateSlug } from "@/lib/utils";
@@ -24,6 +24,10 @@ export const categoryRouter = createTRPCRouter({
return await ctx.db.query.categories.findMany();
}),
getCount: publicProcedure.query(async ({ ctx }) => {
return (await ctx.db.select({ count: count() }).from(categories))[0]?.count;
}),
create: protectedProcedure
.input(z.object({ category: categorySchema }))
.mutation(async ({ ctx, input }) => {