feat: delete workspace

This commit is contained in:
Henry
2024-08-30 22:28:07 +01:00
parent 5c8a1c5069
commit a06500a949
19 changed files with 1647 additions and 365 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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 };
}),

View File

@@ -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,

View File

@@ -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;
}),
});