feat: filter teams with zero members in admin components
- Updated `AdminClientWrapper` to filter out teams with zero members in `getFilteredTeamStats`. - Modified `AdminFilters` to only include directions and teams with members in the options. - Enhanced `AdminService` to generate direction stats based on teams with members, improving data accuracy.
This commit is contained in:
@@ -35,6 +35,9 @@ export function AdminClientWrapper({
|
||||
const getFilteredTeamStats = () => {
|
||||
let filtered = teamStats;
|
||||
|
||||
// Filtrer les équipes avec 0 membres
|
||||
filtered = filtered.filter((team) => team.totalMembers > 0);
|
||||
|
||||
if (selectedDirections.length > 0) {
|
||||
filtered = filtered.filter((team) =>
|
||||
selectedDirections.includes(team.direction)
|
||||
|
||||
@@ -28,18 +28,30 @@ export function AdminFilters({
|
||||
const hasFilters = selectedDirections.length > 0 || selectedTeams.length > 0;
|
||||
|
||||
const directionOptions = Array.from(
|
||||
new Set(teams.map((team) => team.direction))
|
||||
new Set(
|
||||
teamStats
|
||||
.filter((team) => team.totalMembers > 0)
|
||||
.map((team) => team.direction)
|
||||
)
|
||||
).map((direction) => ({
|
||||
id: direction,
|
||||
label: direction,
|
||||
count: teams.filter((team) => team.direction === direction).length,
|
||||
count: teamStats.filter(
|
||||
(team) => team.direction === direction && team.totalMembers > 0
|
||||
).length,
|
||||
}));
|
||||
|
||||
const teamOptions = teams.map((team) => ({
|
||||
id: team.id,
|
||||
label: `${team.name} (${team.direction})`,
|
||||
count: teamStats.find((stat) => stat.teamId === team.id)?.totalMembers || 0,
|
||||
}));
|
||||
const teamOptions = teams
|
||||
.filter((team) => {
|
||||
const teamStat = teamStats.find((stat) => stat.teamId === team.id);
|
||||
return teamStat && teamStat.totalMembers > 0;
|
||||
})
|
||||
.map((team) => ({
|
||||
id: team.id,
|
||||
label: `${team.name} (${team.direction})`,
|
||||
count:
|
||||
teamStats.find((stat) => stat.teamId === team.id)?.totalMembers || 0,
|
||||
}));
|
||||
|
||||
const handleReset = () => {
|
||||
onDirectionsChange([]);
|
||||
|
||||
Reference in New Issue
Block a user