feat: delete workspace
This commit is contained in:
@@ -114,20 +114,20 @@ export const boardRouter = createTRPCRouter({
|
||||
|
||||
const deletedAt = new Date().toISOString();
|
||||
|
||||
await boardRepo.destroy(ctx.db, {
|
||||
await boardRepo.softDelete(ctx.db, {
|
||||
boardId: board.id,
|
||||
deletedAt,
|
||||
deletedBy: userId,
|
||||
});
|
||||
|
||||
if (listIds.length) {
|
||||
await listRepo.destroyAllByBoardId(ctx.db, {
|
||||
await listRepo.softDeleteAllByBoardId(ctx.db, {
|
||||
boardId: board.id,
|
||||
deletedAt,
|
||||
deletedBy: userId,
|
||||
});
|
||||
|
||||
await cardRepo.destroyAllByListIds(ctx.db, {
|
||||
await cardRepo.softDeleteAllByListIds(ctx.db, {
|
||||
listIds,
|
||||
deletedAt,
|
||||
deletedBy: userId,
|
||||
|
||||
@@ -149,7 +149,7 @@ export const cardRouter = createTRPCRouter({
|
||||
);
|
||||
|
||||
if (existingLabel) {
|
||||
await cardRepo.destroyCardLabelRelationship(ctx.db, cardLabelIds);
|
||||
await cardRepo.hardDeleteCardLabelRelationship(ctx.db, cardLabelIds);
|
||||
|
||||
return { newLabel: false };
|
||||
}
|
||||
@@ -200,7 +200,7 @@ export const cardRouter = createTRPCRouter({
|
||||
);
|
||||
|
||||
if (existingMember) {
|
||||
await cardRepo.destroyCardMemberRelationship(ctx.db, cardMemberIds);
|
||||
await cardRepo.hardDeleteCardMemberRelationship(ctx.db, cardMemberIds);
|
||||
|
||||
return { newMember: false };
|
||||
}
|
||||
@@ -272,7 +272,7 @@ export const cardRouter = createTRPCRouter({
|
||||
|
||||
const deletedAt = new Date().toISOString();
|
||||
|
||||
await cardRepo.destroy(ctx.db, {
|
||||
await cardRepo.softDelete(ctx.db, {
|
||||
cardId: card.id,
|
||||
deletedAt,
|
||||
deletedBy: userId,
|
||||
|
||||
@@ -81,9 +81,9 @@ export const labelRouter = createTRPCRouter({
|
||||
code: "NOT_FOUND",
|
||||
});
|
||||
|
||||
await cardRepo.destroyAllCardLabelRelationships(ctx.db, label.id);
|
||||
await cardRepo.hardDeleteAllCardLabelRelationships(ctx.db, label.id);
|
||||
|
||||
await labelRepo.destroy(ctx.db, label.id);
|
||||
await labelRepo.hardDelete(ctx.db, label.id);
|
||||
|
||||
return { success: true };
|
||||
}),
|
||||
|
||||
@@ -98,13 +98,13 @@ export const listRouter = createTRPCRouter({
|
||||
|
||||
const deletedAt = new Date().toISOString();
|
||||
|
||||
await listRepo.destroyById(ctx.db, {
|
||||
await listRepo.softDeleteById(ctx.db, {
|
||||
listId: list.id,
|
||||
deletedAt,
|
||||
deletedBy: userId,
|
||||
});
|
||||
|
||||
await cardRepo.destroyAllByListIds(ctx.db, {
|
||||
await cardRepo.softDeleteAllByListIds(ctx.db, {
|
||||
listIds: [list.id],
|
||||
deletedAt,
|
||||
deletedBy: userId,
|
||||
|
||||
@@ -49,6 +49,22 @@ export const workspaceRouter = createTRPCRouter({
|
||||
createdBy: userId,
|
||||
});
|
||||
|
||||
if (!result?.publicId)
|
||||
throw new TRPCError({
|
||||
message: `Unable to create workspace`,
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
});
|
||||
|
||||
return result;
|
||||
}),
|
||||
delete: protectedProcedure
|
||||
.input(z.object({ workspacePublicId: z.string().min(12) }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const { data } = await workspaceRepo.hardDelete(
|
||||
ctx.db,
|
||||
input.workspacePublicId,
|
||||
);
|
||||
|
||||
return data;
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user