feat: remove a skill category empty

This commit is contained in:
Julien Froidefond
2025-08-26 07:10:26 +02:00
parent e12816a9c2
commit d7fef0be9b
8 changed files with 176 additions and 4 deletions

View File

@@ -20,6 +20,8 @@ interface TreeCategoryHeaderProps {
totalMembers: number;
hasMembers: boolean;
};
onDeleteCategory?: (categoryName: string) => void; // Nouvelle prop pour supprimer les catégories de skills
canDeleteCategory?: boolean; // Si la catégorie peut être supprimée
}
export function TreeCategoryHeader({
@@ -34,6 +36,8 @@ export function TreeCategoryHeader({
canDelete = true,
isDirection = false,
directionStats,
onDeleteCategory,
canDeleteCategory = false,
}: TreeCategoryHeaderProps) {
return (
<div>
@@ -85,6 +89,26 @@ export function TreeCategoryHeader({
<Trash2 className="w-3 h-3" />
</Button>
)}
{/* Bouton de suppression pour les catégories de skills vides */}
{!isDirection && onDeleteCategory && itemCount === 0 && (
<Button
variant="ghost"
size="sm"
onClick={(e) => {
e.stopPropagation(); // Empêcher l'ouverture/fermeture
onDeleteCategory(category);
}}
className="text-red-400 hover:text-red-300 hover:bg-red-500/20 h-6 w-6 p-0"
disabled={!canDeleteCategory}
title={
canDeleteCategory
? `Supprimer la catégorie "${category}"`
: `Impossible de supprimer la catégorie "${category}"`
}
>
<Trash2 className="w-3 h-3" />
</Button>
)}
</div>
</div>
</div>