feat: remove topics

This commit is contained in:
2025-01-24 12:24:44 +01:00
parent e2d3e75311
commit f84c864dd4
2 changed files with 33 additions and 3 deletions

View File

@@ -58,5 +58,22 @@ export const actions = {
.values({ taskId: Number(params.id), topicId })
.returning();
}
},
removeTopic: async ({ request, params }) => {
const data = await request.formData();
const topicId = Number(data.get('topic-id'));
const existing = await db.query.tasksToTopics.findFirst({
where: and(eq(tasksToTopics.taskId, Number(params.id)), eq(tasksToTopics.topicId, topicId))
});
if (existing) {
await db
.delete(tasksToTopics)
.where(
and(eq(tasksToTopics.taskId, Number(params.id)), eq(tasksToTopics.topicId, topicId))
);
}
}
};