feat: add linked item management to action updates in SWOT analysis
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 5s

This commit is contained in:
Julien Froidefond
2025-12-15 13:34:09 +01:00
parent 0cf7437efe
commit d735e1c4c5
3 changed files with 87 additions and 1 deletions

View File

@@ -305,11 +305,39 @@ export async function updateAction(
priority?: number;
status?: string;
dueDate?: Date | null;
linkedItemIds?: string[];
}
) {
const { linkedItemIds, ...updateData } = data;
// If linkedItemIds is provided, update the links
if (linkedItemIds !== undefined) {
// Delete all existing links
await prisma.actionLink.deleteMany({
where: { actionId },
});
// Create new links
if (linkedItemIds.length > 0) {
await prisma.actionLink.createMany({
data: linkedItemIds.map((swotItemId) => ({
actionId,
swotItemId,
})),
});
}
}
return prisma.action.update({
where: { id: actionId },
data,
data: updateData,
include: {
links: {
include: {
swotItem: true,
},
},
},
});
}