feat: update label

This commit is contained in:
Henry
2024-08-27 23:34:52 +01:00
parent 2adcac85a4
commit 583256a46b
6 changed files with 145 additions and 38 deletions

View File

@@ -7,6 +7,19 @@ import * as cardRepo from "~/server/db/repository/card.repo";
import * as labelRepo from "~/server/db/repository/label.repo";
export const labelRouter = createTRPCRouter({
byPublicId: protectedProcedure
.input(z.object({ publicId: z.string().min(12) }))
.query(async ({ ctx, input }) => {
const label = await labelRepo.getByPublicId(ctx.db, input.publicId);
if (!label)
throw new TRPCError({
message: `Label with public ID ${input.publicId} not found`,
code: "NOT_FOUND",
});
return label;
}),
create: protectedProcedure
.input(
z.object({
@@ -42,6 +55,19 @@ export const labelRouter = createTRPCRouter({
boardId: card.list.boardId,
});
return result;
}),
update: protectedProcedure
.input(
z.object({
publicId: z.string().min(12),
name: z.string().min(1).max(36),
colourCode: z.string().length(7),
}),
)
.mutation(async ({ ctx, input }) => {
const result = await labelRepo.update(ctx.db, input);
return result;
}),
});