feat: add workspace member assertion to list router

This commit is contained in:
Henry
2025-05-23 13:43:51 +01:00
parent 2e97e2be53
commit a6c6524749
5 changed files with 116 additions and 37 deletions

View File

@@ -218,18 +218,15 @@ export const importRouter = createTRPCRouter({
.filter((label) => !!label.sourceId);
}
let listIndex = 0;
for (const list of formattedData.lists) {
const newList = await listRepo.create(ctx.db, {
name: list.name,
createdBy: userId,
boardId: newBoardId,
index: listIndex,
importId: newImportId,
});
const newListId = newList?.id;
const newListId = newList.id;
if (list.cards.length && newListId) {
const cardsInsert = list.cards.map((card, index) => ({
@@ -244,7 +241,7 @@ export const importRouter = createTRPCRouter({
const newCards = await cardRepo.bulkCreate(ctx.db, cardsInsert);
if (!newCards?.length)
if (!newCards.length)
throw new TRPCError({
message: "Failed to create new cards",
code: "INTERNAL_SERVER_ERROR",
@@ -302,8 +299,6 @@ export const importRouter = createTRPCRouter({
}
}
}
listIndex++;
}
boardsCreated++;