feat: add duplicate functionality for SWOT items, enhance ActionPanel layout, and update SwotCard with duplicate action

This commit is contained in:
Julien Froidefond
2025-11-27 13:22:57 +01:00
parent 628d64a5c6
commit 9ce2b62bc6
5 changed files with 124 additions and 53 deletions

View File

@@ -109,6 +109,31 @@ export async function deleteSwotItem(itemId: string) {
});
}
export async function duplicateSwotItem(itemId: string) {
const original = await prisma.swotItem.findUnique({
where: { id: itemId },
});
if (!original) {
throw new Error('Item not found');
}
// Get max order for this category
const maxOrder = await prisma.swotItem.aggregate({
where: { sessionId: original.sessionId, category: original.category },
_max: { order: true },
});
return prisma.swotItem.create({
data: {
content: original.content,
category: original.category,
sessionId: original.sessionId,
order: (maxOrder._max.order ?? -1) + 1,
},
});
}
export async function reorderSwotItems(
sessionId: string,
category: SwotCategory,