feat: add linked item management to action updates in SWOT analysis
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 5s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 5s
This commit is contained in:
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user