feat: add duplicate functionality for SWOT items, enhance ActionPanel layout, and update SwotCard with duplicate action
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user