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} {itemLabel}
|
||||||
{itemCount > 1 ? "s" : ""}
|
{itemCount > 1 ? "s" : ""}
|
||||||
</Badge>
|
</Badge>
|
||||||
{isDirection && onDelete && canDelete && (
|
{isDirection && onDelete && (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -75,7 +75,12 @@ export function TreeCategoryHeader({
|
|||||||
onDelete();
|
onDelete();
|
||||||
}}
|
}}
|
||||||
className="text-red-400 hover:text-red-300 hover:bg-red-500/20 h-6 w-6 p-0"
|
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" />
|
<Trash2 className="w-3 h-3" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export function TeamsList({
|
|||||||
itemLabel="équipe"
|
itemLabel="équipe"
|
||||||
showSeparator={index > 0}
|
showSeparator={index > 0}
|
||||||
onDelete={() => onDeleteDirection(direction)}
|
onDelete={() => onDeleteDirection(direction)}
|
||||||
canDelete={true}
|
canDelete={!getDirectionStats(direction).hasMembers}
|
||||||
isDirection={true}
|
isDirection={true}
|
||||||
directionStats={getDirectionStats(direction)}
|
directionStats={getDirectionStats(direction)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user