feat: total members on direction line manage
This commit is contained in:
@@ -15,6 +15,11 @@ interface TreeCategoryHeaderProps {
|
|||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
canDelete?: boolean;
|
canDelete?: boolean;
|
||||||
isDirection?: boolean; // Pour différencier les directions des catégories de skills
|
isDirection?: boolean; // Pour différencier les directions des catégories de skills
|
||||||
|
directionStats?: {
|
||||||
|
direction: string;
|
||||||
|
totalMembers: number;
|
||||||
|
hasMembers: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TreeCategoryHeader({
|
export function TreeCategoryHeader({
|
||||||
@@ -28,6 +33,7 @@ export function TreeCategoryHeader({
|
|||||||
onDelete,
|
onDelete,
|
||||||
canDelete = true,
|
canDelete = true,
|
||||||
isDirection = false,
|
isDirection = false,
|
||||||
|
directionStats,
|
||||||
}: TreeCategoryHeaderProps) {
|
}: TreeCategoryHeaderProps) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -47,6 +53,15 @@ export function TreeCategoryHeader({
|
|||||||
{icon}
|
{icon}
|
||||||
<h3 className="text-base font-semibold text-white">{category}</h3>
|
<h3 className="text-base font-semibold text-white">{category}</h3>
|
||||||
<div className="flex items-center gap-2 ml-auto">
|
<div className="flex items-center gap-2 ml-auto">
|
||||||
|
{isDirection && directionStats && directionStats.hasMembers && (
|
||||||
|
<Badge
|
||||||
|
variant="secondary"
|
||||||
|
className="text-xs px-2 py-0.5 bg-blue-500/20 text-blue-300 border-blue-500/30"
|
||||||
|
>
|
||||||
|
{directionStats.totalMembers} membre
|
||||||
|
{directionStats.totalMembers > 1 ? "s" : ""}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
<Badge variant="outline" className="text-xs px-2 py-0.5">
|
<Badge variant="outline" className="text-xs px-2 py-0.5">
|
||||||
{itemCount} {itemLabel}
|
{itemCount} {itemLabel}
|
||||||
{itemCount > 1 ? "s" : ""}
|
{itemCount > 1 ? "s" : ""}
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ interface TeamsListProps {
|
|||||||
onDeleteDirection: (direction: string) => void;
|
onDeleteDirection: (direction: string) => void;
|
||||||
onViewMembers: (team: TeamType) => void;
|
onViewMembers: (team: TeamType) => void;
|
||||||
getTeamStats: (teamId: string) => TeamStats | undefined;
|
getTeamStats: (teamId: string) => TeamStats | undefined;
|
||||||
|
getDirectionStats: (direction: string) => {
|
||||||
|
direction: string;
|
||||||
|
totalMembers: number;
|
||||||
|
hasMembers: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TeamsList({
|
export function TeamsList({
|
||||||
@@ -29,6 +34,7 @@ export function TeamsList({
|
|||||||
onDeleteDirection,
|
onDeleteDirection,
|
||||||
onViewMembers,
|
onViewMembers,
|
||||||
getTeamStats,
|
getTeamStats,
|
||||||
|
getDirectionStats,
|
||||||
}: TeamsListProps) {
|
}: TeamsListProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -46,6 +52,7 @@ export function TeamsList({
|
|||||||
onDelete={() => onDeleteDirection(direction)}
|
onDelete={() => onDeleteDirection(direction)}
|
||||||
canDelete={true}
|
canDelete={true}
|
||||||
isDirection={true}
|
isDirection={true}
|
||||||
|
directionStats={getDirectionStats(direction)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Liste des teams de la direction */}
|
{/* Liste des teams de la direction */}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export function TeamsManagementPage({
|
|||||||
setTeamFormData,
|
setTeamFormData,
|
||||||
resetForm,
|
resetForm,
|
||||||
getTeamStats,
|
getTeamStats,
|
||||||
|
getDirectionStats,
|
||||||
handleCreateTeam,
|
handleCreateTeam,
|
||||||
handleEditTeam,
|
handleEditTeam,
|
||||||
handleUpdateTeam,
|
handleUpdateTeam,
|
||||||
@@ -145,6 +146,7 @@ export function TeamsManagementPage({
|
|||||||
onDeleteDirection={handleDeleteDirection}
|
onDeleteDirection={handleDeleteDirection}
|
||||||
onViewMembers={handleViewMembers}
|
onViewMembers={handleViewMembers}
|
||||||
getTeamStats={getTeamStats}
|
getTeamStats={getTeamStats}
|
||||||
|
getDirectionStats={getDirectionStats}
|
||||||
/>
|
/>
|
||||||
</TreeViewPage>
|
</TreeViewPage>
|
||||||
|
|
||||||
|
|||||||
@@ -224,6 +224,23 @@ export function useTeamsManagement(
|
|||||||
// Extraire les directions uniques pour les formulaires
|
// Extraire les directions uniques pour les formulaires
|
||||||
const directions = Array.from(new Set(teams.map((team) => team.direction)));
|
const directions = Array.from(new Set(teams.map((team) => team.direction)));
|
||||||
|
|
||||||
|
// Calculer les stats par direction
|
||||||
|
const getDirectionStats = (direction: string) => {
|
||||||
|
const teamsInDirection = teams.filter(
|
||||||
|
(team) => team.direction === direction
|
||||||
|
);
|
||||||
|
const totalMembers = teamsInDirection.reduce((total, team) => {
|
||||||
|
const stats = getTeamStats(team.id);
|
||||||
|
return total + (stats?.totalMembers || 0);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return {
|
||||||
|
direction,
|
||||||
|
totalMembers,
|
||||||
|
hasMembers: totalMembers > 0,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
teams,
|
teams,
|
||||||
teamStats,
|
teamStats,
|
||||||
@@ -234,6 +251,7 @@ export function useTeamsManagement(
|
|||||||
setTeamFormData,
|
setTeamFormData,
|
||||||
resetForm,
|
resetForm,
|
||||||
getTeamStats,
|
getTeamStats,
|
||||||
|
getDirectionStats,
|
||||||
handleCreateTeam,
|
handleCreateTeam,
|
||||||
handleEditTeam,
|
handleEditTeam,
|
||||||
handleUpdateTeam,
|
handleUpdateTeam,
|
||||||
|
|||||||
Reference in New Issue
Block a user