diff --git a/ui/modules/admin/users/UsersFiltersPanel.tsx b/ui/modules/admin/users/UsersFiltersPanel.tsx index a982747d1..682d107e9 100644 --- a/ui/modules/admin/users/UsersFiltersPanel.tsx +++ b/ui/modules/admin/users/UsersFiltersPanel.tsx @@ -9,6 +9,7 @@ import { } from "@/modules/models/pagination"; import FiltreUsersAccountStatut from "./filters/FiltreUsersAccountStatut"; +import FiltreUsersReseaux from "./filters/FiltreUsersReseaux"; import FiltreUserTypes from "./filters/FiltreUsersType"; import { UsersFilters, @@ -72,6 +73,7 @@ const UsersFiltersPanel = () => { /> {/* FILTRE Réseau */} + updateState({ reseaux })} /> {/* FILTRE Statut du compte */} void; +} + +function FiltreUsersReseaux(props: FiltreUsersReseauxTypesProps) { + const [isOpen, setIsOpen] = useState(false); + const reseaux = props.value; + + return ( +
+ + {isOpen && ( + setIsOpen(false)} width="auto" p="3w"> + props.onChange(selectedReseaux)} + > + + {TETE_DE_RESEAUX_SORTED.map((reseau, i) => ( + + {reseau.nom} + + ))} + + + + )} +
+ ); +} + +export default FiltreUsersReseaux; diff --git a/ui/modules/admin/users/models/users-filters.ts b/ui/modules/admin/users/models/users-filters.ts index 7f8ecd46e..91b77a452 100644 --- a/ui/modules/admin/users/models/users-filters.ts +++ b/ui/modules/admin/users/models/users-filters.ts @@ -5,17 +5,20 @@ import { UserNormalized } from "./users"; export interface UsersFilters { type_utilisateur: string[]; account_status: string[]; + reseaux: string[]; } export interface UsersFiltersQuery { type_utilisateur?: string; account_status?: string; + reseaux?: string; } export function parseUsersFiltersFromQuery(query: UsersFiltersQuery): UsersFilters { return { type_utilisateur: query.type_utilisateur?.split(",") ?? [], account_status: query.account_status?.split(",") ?? [], + reseaux: query.reseaux?.split(",") ?? [], }; } @@ -23,6 +26,7 @@ export function convertUsersFiltersToQuery(organismesFilters: Partial 0) filteredUsers = filteredUsers?.filter((item) => usersFilters.account_status?.includes(item.account_status)); + if (usersFilters.reseaux?.length && usersFilters.reseaux?.length > 0) + filteredUsers = filteredUsers?.filter( + (item) => + item.organismeReseaux.length > 0 && + item.organismeReseaux.some((reseau) => usersFilters.reseaux?.includes(reseau)) + ); + return filteredUsers; } diff --git a/ui/modules/admin/users/models/users.ts b/ui/modules/admin/users/models/users.ts index c8a721253..05a3a65d3 100644 --- a/ui/modules/admin/users/models/users.ts +++ b/ui/modules/admin/users/models/users.ts @@ -16,6 +16,7 @@ export type UserNormalized = { userType: string; organismeId: string; organismeNom: string; + organismeReseaux: string[]; nom: string; prenom: string; account_status: string; @@ -28,10 +29,13 @@ export type UserNormalized = { export const toUserNormalized = (user: User): UserNormalized => { const organismeId = user?.organisation?.organisme?._id; const organismeNom = user?.organisation?.organisme?.nom || user?.organisation?.label || ""; + const organismeReseaux = user?.organisation?.organisme?.reseaux || []; + return { ...user, organismeId, organismeNom, + organismeReseaux, created_at: formatDateDayMonthYear(user.created_at), organisationType: user?.organisation?.label || "", userType: user?.organisation?.type || "",