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:
@@ -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>
|
||||
|
||||
@@ -50,7 +50,7 @@ export function TeamsList({
|
||||
itemLabel="équipe"
|
||||
showSeparator={index > 0}
|
||||
onDelete={() => onDeleteDirection(direction)}
|
||||
canDelete={true}
|
||||
canDelete={!getDirectionStats(direction).hasMembers}
|
||||
isDirection={true}
|
||||
directionStats={getDirectionStats(direction)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user