feat: total members on direction line manage
This commit is contained in:
@@ -224,6 +224,23 @@ export function useTeamsManagement(
|
||||
// Extraire les directions uniques pour les formulaires
|
||||
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 {
|
||||
teams,
|
||||
teamStats,
|
||||
@@ -234,6 +251,7 @@ export function useTeamsManagement(
|
||||
setTeamFormData,
|
||||
resetForm,
|
||||
getTeamStats,
|
||||
getDirectionStats,
|
||||
handleCreateTeam,
|
||||
handleEditTeam,
|
||||
handleUpdateTeam,
|
||||
|
||||
Reference in New Issue
Block a user