fix: update delete button behavior in TreeCategoryHeader and TeamsList

- Removed unnecessary canDelete prop from TreeCategoryHeader's delete button condition.
- Added disabled state to the delete button based on canDelete logic.
- Updated canDelete prop in TeamsList to reflect whether the direction has members.
This commit is contained in:
Julien Froidefond
2025-08-25 22:00:40 +02:00
parent 3b8f3e4110
commit e8138ebcb3
2 changed files with 8 additions and 3 deletions

View File

@@ -66,7 +66,7 @@ export function TreeCategoryHeader({
{itemCount} {itemLabel}
{itemCount > 1 ? "s" : ""}
</Badge>
{isDirection && onDelete && canDelete && (
{isDirection && onDelete && (
<Button
variant="ghost"
size="sm"
@@ -75,7 +75,12 @@ export function TreeCategoryHeader({
onDelete();
}}
className="text-red-400 hover:text-red-300 hover:bg-red-500/20 h-6 w-6 p-0"
title={`Supprimer la direction "${category}" et toutes ses équipes`}
disabled={!canDelete}
title={
canDelete
? `Supprimer la direction "${category}" et toutes ses équipes`
: `Impossible de supprimer la direction "${category}" car elle contient des membres`
}
>
<Trash2 className="w-3 h-3" />
</Button>