Skip to content

Commit

Permalink
Ajoute la possibilité de donner des valeurs custom aux badges des lis…
Browse files Browse the repository at this point in the history
…tes Indicateur et FicheAction
  • Loading branch information
cparthur committed Dec 9, 2024
1 parent 93a6d1f commit 4d0469b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import {
useExportIndicateurs,
} from '@tet/app/pages/collectivite/Indicateurs/Indicateur/useExportIndicateurs';
import FilterBadges, {
CustomFilterBadges,
useFiltersToBadges,
} from 'ui/shared/filters/filter-badges';

type Props = {
pageName: ExportIndicateursPageName; // tracking
definitions?: Indicateurs.domain.IndicateurListItem[];
filters: Indicateurs.FetchFiltre;
customFilterBadges?: CustomFilterBadges;
resetFilters?: () => void;
isLoading: boolean;
isEmpty: boolean;
Expand All @@ -24,6 +26,7 @@ const BadgeList = ({
pageName,
definitions,
filters,
customFilterBadges,
resetFilters,
isEmpty,
isLoading,
Expand All @@ -32,7 +35,10 @@ const BadgeList = ({
const { mutate: exportIndicateurs, isLoading: isDownloadingExport } =
useExportIndicateurs(pageName, definitions);

const { data: filterBadges } = useFiltersToBadges({ filters });
const { data: filterBadges } = useFiltersToBadges({
filters,
customValues: customFilterBadges,
});

return (
<div className="flex flex-row justify-between items-start">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { makeCollectiviteIndicateursUrl } from 'app/paths';
import { useCurrentCollectivite } from 'core-logic/hooks/useCurrentCollectivite';
import BadgeList from '@tet/app/pages/collectivite/Indicateurs/lists/indicateurs-list/badge-list';
import { ExportIndicateursPageName } from '@tet/app/pages/collectivite/Indicateurs/Indicateur/useExportIndicateurs';
import { CustomFilterBadges } from 'ui/shared/filters/filter-badges';

type sortByOptionsType = {
label: string;
Expand Down Expand Up @@ -51,6 +52,7 @@ const sortByOptions: sortByOptionsType[] = [
type Props = {
settings: (openState: OpenState) => React.ReactNode;
filtres?: Indicateurs.FetchFiltre;
customFilterBadges?: CustomFilterBadges;
resetFilters?: () => void;
maxNbOfCards?: number;
sortSettings?: SortIndicateurSettings;
Expand All @@ -67,6 +69,7 @@ const IndicateursListe = ({
defaultSort: 'text',
},
filtres = {},
customFilterBadges,
resetFilters,
settings,
isEditable,
Expand Down Expand Up @@ -205,6 +208,7 @@ const IndicateursListe = ({
pageName={pageName}
definitions={definitions}
filters={filtres}
customFilterBadges={customFilterBadges}
resetFilters={resetFilters}
isLoading={isLoading}
isEmpty={currentDefs?.length === 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
makeCollectivitePlanActionFicheUrl,
} from 'app/paths';
import FilterBadges, {
CustomFilterBadges,
useFiltersToBadges,
} from 'ui/shared/filters/filter-badges';

Expand Down Expand Up @@ -52,8 +53,9 @@ const sortByOptions: sortByOptionsType[] = [
];

type Props = {
filtres: Filtre;
settings: (openState: OpenState) => React.ReactNode;
filtres: Filtre;
customFilterBadges?: CustomFilterBadges;
resetFilters?: () => void;
maxNbOfCards?: number;
sortSettings?: SortFicheActionSettings;
Expand All @@ -65,6 +67,7 @@ const FichesActionListe = ({
defaultSort: 'modified_at',
},
filtres,
customFilterBadges,
resetFilters,
settings,
maxNbOfCards = 15,
Expand Down Expand Up @@ -133,7 +136,10 @@ const FichesActionListe = ({

const countTotal = data?.count || 0;

const { data: filterBadges } = useFiltersToBadges({ filters: filtres });
const { data: filterBadges } = useFiltersToBadges({
filters: filtres,
customValues: customFilterBadges,
});

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import FichesActionListe, {
import ModulePage from '@tet/app/pages/collectivite/TableauDeBord/components/ModulePage';
import ModalActionsDontJeSuisLePilote from '@tet/app/pages/collectivite/TableauDeBord/Personnel/ModuleFichesActions/ModalActionsDontJeSuisLePilote';
import ModalActionsRecemmentModifiees from '@tet/app/pages/collectivite/TableauDeBord/Personnel/ModuleFichesActions/ModalActionsRecemmentModifiees';
import { usePlanActionsCount } from '@tet/app/pages/collectivite/PlansActions/PlanAction/data/usePlanActionsCount';

type Props = {
view: TDBViewParam;
Expand All @@ -30,6 +31,7 @@ const ModuleFichesActionsPage = ({ view, slug, sortSettings }: Props) => {
const { data: dataModule, isLoading: isModuleLoading } =
usePersonalModuleFetch(slug);
const module = dataModule as ModuleFicheActionsSelect;
const { count } = usePlanActionsCount();

const trackEvent = useEventTracker(`app/tdb/personnel/${slug}`);

Expand All @@ -45,6 +47,11 @@ const ModuleFichesActionsPage = ({ view, slug, sortSettings }: Props) => {
/>
<FichesActionListe
filtres={module.options.filtre}
customFilterBadges={{
planActions:
module.options.filtre?.planActionIds?.length === count &&
'Tous les plans',
}}
sortSettings={sortSettings}
settings={(openState) => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@tet/app/pages/collectivite/TableauDeBord/Personnel/usePersonalModuleFetch';
import { TDBViewParam } from 'app/paths';
import { useCollectiviteId } from 'core-logic/hooks/params';
import { usePlanActionsCount } from '@tet/app/pages/collectivite/PlansActions/PlanAction/data/usePlanActionsCount';

type Props = {
view: TDBViewParam;
Expand All @@ -27,6 +28,8 @@ const ModuleIndicateursPage = ({ view, slug }: Props) => {

const filtre = module?.options.filtre;

const { count } = usePlanActionsCount();

const pageName = 'app/tdb/personnel/indicateurs-de-suivi-de-mes-plans';
const trackEvent = useEventTracker(pageName);

Expand All @@ -43,6 +46,10 @@ const ModuleIndicateursPage = ({ view, slug }: Props) => {
<IndicateursListe
pageName={pageName}
filtres={filtre}
customFilterBadges={{
planActions:
filtre?.planActionIds?.length === count && 'Tous les plans',
}}
settings={(openState) => (
<>
<Button
Expand Down

0 comments on commit 4d0469b

Please sign in to comment.