feat: update label
This commit is contained in:
@@ -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;
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user