diff --git a/ui/modules/organismes/OrganismesFilterPanel.tsx b/ui/modules/organismes/OrganismesFilterPanel.tsx index 4132ed5b0..275f7896c 100644 --- a/ui/modules/organismes/OrganismesFilterPanel.tsx +++ b/ui/modules/organismes/OrganismesFilterPanel.tsx @@ -16,6 +16,7 @@ import FiltreOrganismesEtat from "./filters/FiltreOrganismeEtat"; import FiltreOrganismesNature from "./filters/FiltreOrganismeNature"; import FiltreOrganismeRegions from "./filters/FiltreOrganismeRegions"; import FiltreOrganismeTransmission from "./filters/FiltreOrganismeTransmission"; +import FiltreOrganismeUai from "./filters/FiltreOrganismeUai"; import FiltreYesNo from "./filters/FiltreYesNo"; import { OrganismesFilters, @@ -25,6 +26,7 @@ import { } from "./models/organismes-filters"; export interface OrganismeFiltersListVisibilityProps { + showFilterUai?: boolean; showFilterNature?: boolean; showFilterTransmission?: boolean; showFilterQualiopi?: boolean; @@ -103,6 +105,16 @@ const OrganismesFilterPanel = (props: OrganismeFiltersListVisibilityProps) => { } }; + const isAllowedToShowFilterUAI = (type: OrganisationType) => { + switch (type) { + case "ADMINISTRATEUR": + return true; + + default: + return false; + } + }; + return ( @@ -127,6 +139,11 @@ const OrganismesFilterPanel = (props: OrganismeFiltersListVisibilityProps) => { updateState({ nature })} /> )} + {/* FILTRE UAI */} + {props?.showFilterUai && isAllowedToShowFilterUAI(auth?.organisation?.type) && ( + updateState({ etatUAI })} /> + )} + {/* FILTRE TRANSMISSION */} {props?.showFilterTransmission && ( void; +} + +function FiltreOrganismeUai(props: FiltreOrganismeUaiProps) { + const [isOpen, setIsOpen] = useState(false); + const etatUAI = props.value; + + return ( +
+ + {isOpen && ( + setIsOpen(false)} width="auto" p="3w"> + item.toString())} + onChange={(value) => props.onChange(value.map((v: string) => (v === "true" ? true : false)))} + > + + + Connu + + + Inconnu + + + + + )} +
+ ); +} + +export default FiltreOrganismeUai; diff --git a/ui/modules/organismes/models/organismes-filters.ts b/ui/modules/organismes/models/organismes-filters.ts index 000bf1a9c..c65c13337 100644 --- a/ui/modules/organismes/models/organismes-filters.ts +++ b/ui/modules/organismes/models/organismes-filters.ts @@ -10,6 +10,7 @@ export interface OrganismesFiltersQuery { ferme: string; regions?: string; departements?: string; + etatUAI: string; } export interface OrganismesFilters { @@ -20,6 +21,7 @@ export interface OrganismesFilters { ferme: boolean[]; regions: string[]; departements: string[]; + etatUAI: boolean[]; } export function parseOrganismesFiltersFromQuery(query: OrganismesFiltersQuery): OrganismesFilters { @@ -31,6 +33,7 @@ export function parseOrganismesFiltersFromQuery(query: OrganismesFiltersQuery): ferme: query.ferme?.split(",").map((item) => (item === "true" ? true : false)) ?? [], regions: query.regions?.split(",") ?? [], departements: query.departements?.split(",") ?? [], + etatUAI: query.etatUAI?.split(",").map((item) => (item === "true" ? true : false)) ?? [], }; } @@ -45,6 +48,7 @@ export function convertOrganismesFiltersToQuery( ferme: organismesFilters.ferme?.join(","), regions: organismesFilters.regions?.join(","), departements: organismesFilters.departements?.join(","), + etatUAI: organismesFilters.etatUAI?.join(","), }); } @@ -86,11 +90,18 @@ export function filterOrganismesArrayFromOrganismesFilters( return organismesFilters.departements?.includes(item.adresse.departement); }); - if (organismesFilters.transmission?.length && organismesFilters.transmission?.length === 1) - filteredOrganismes = filteredOrganismes?.filter((item) => { - if (organismesFilters.transmission?.[0] === true) return item.last_transmission_date; - if (organismesFilters.transmission?.[0] === false) return !item.last_transmission_date; - }); + if (organismesFilters.transmission?.length && organismesFilters.transmission?.length > 0) + filteredOrganismes = filteredOrganismes?.filter( + (item) => + organismesFilters.transmission?.some( + (filter) => (!!filter && !!item.last_transmission_date) || (!filter && !item.last_transmission_date) + ) + ); + + if (organismesFilters.etatUAI?.length && organismesFilters.etatUAI?.length > 0) + filteredOrganismes = filteredOrganismes?.filter( + (item) => organismesFilters.etatUAI?.some((filter) => (!!filter && !!item.uai) || (!filter && !item.uai)) + ); return filteredOrganismes; } diff --git a/ui/modules/organismes/tabs/OrganismesACompleterPanelContent.tsx b/ui/modules/organismes/tabs/OrganismesACompleterPanelContent.tsx index 02cd381c7..3ef2ef38c 100644 --- a/ui/modules/organismes/tabs/OrganismesACompleterPanelContent.tsx +++ b/ui/modules/organismes/tabs/OrganismesACompleterPanelContent.tsx @@ -66,6 +66,7 @@ function OrganismesACompleterPanelContent({ organismes }: { organismes: Organism showFilterTransmission showFilterLocalisation showFilterEtat + showFilterUai />
);