diff --git a/dev.db b/dev.db index 580e910..44e532a 100644 Binary files a/dev.db and b/dev.db differ diff --git a/src/actions/swot.ts b/src/actions/swot.ts index a075cbf..997348d 100644 --- a/src/actions/swot.ts +++ b/src/actions/swot.ts @@ -64,6 +64,22 @@ export async function deleteSwotItem(itemId: string, sessionId: string) { } } +export async function duplicateSwotItem(itemId: string, sessionId: string) { + const session = await auth(); + if (!session?.user?.id) { + return { success: false, error: 'Non autorisé' }; + } + + try { + const item = await sessionsService.duplicateSwotItem(itemId); + revalidatePath(`/sessions/${sessionId}`); + return { success: true, data: item }; + } catch (error) { + console.error('Error duplicating SWOT item:', error); + return { success: false, error: 'Erreur lors de la duplication' }; + } +} + export async function moveSwotItem( itemId: string, sessionId: string, diff --git a/src/components/swot/ActionPanel.tsx b/src/components/swot/ActionPanel.tsx index 95d7e55..417abc9 100644 --- a/src/components/swot/ActionPanel.tsx +++ b/src/components/swot/ActionPanel.tsx @@ -172,64 +172,24 @@ export function ActionPanel({ Créez des actions en sélectionnant plusieurs items SWOT.

) : ( -
+
{actions.map((action) => (
onActionHover(action.links.map((l) => l.swotItemId))} onMouseLeave={onActionLeave} > -
-
-
-

{action.title}

- - {priorityLabels[action.priority]} - -
- {action.description && ( -

{action.description}

- )} -
- {action.links.map((link) => ( - - {categoryShort[link.swotItem.category]} - - ))} -
-
- -
- - + {/* Header with title & actions */} +
+

{action.title}

+
-
+ + {/* Description */} + {action.description && ( +

{action.description}

+ )} + + {/* Linked Items */} +
+ {action.links.map((link) => ( + + + {link.swotItem.content.length > 25 + ? link.swotItem.content.slice(0, 25) + '...' + : link.swotItem.content} + + + ))} +
+ + {/* Footer with status & priority */} +
+ + {priorityLabels[action.priority]} + + +
))}
diff --git a/src/components/swot/SwotCard.tsx b/src/components/swot/SwotCard.tsx index 29f60fa..7f1e1dc 100644 --- a/src/components/swot/SwotCard.tsx +++ b/src/components/swot/SwotCard.tsx @@ -2,7 +2,7 @@ import { forwardRef, useState, useTransition } from 'react'; import type { SwotItem, SwotCategory } from '@prisma/client'; -import { updateSwotItem, deleteSwotItem } from '@/actions/swot'; +import { updateSwotItem, deleteSwotItem, duplicateSwotItem } from '@/actions/swot'; interface SwotCardProps { item: SwotItem; @@ -58,6 +58,12 @@ export const SwotCard = forwardRef( }); } + async function handleDuplicate() { + startTransition(async () => { + await duplicateSwotItem(item.id, sessionId); + }); + } + function handleKeyDown(e: React.KeyboardEvent) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); @@ -105,7 +111,7 @@ export const SwotCard = forwardRef( {/* Actions (visible on hover) */} {!linkMode && ( -
+
+