diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/indicateurs-list/indicateurs-list.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/indicateurs-list/indicateurs-list.tsx index 5ca457f83b..6815e83330 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/indicateurs-list/indicateurs-list.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/indicateurs-list/indicateurs-list.tsx @@ -257,15 +257,14 @@ const IndicateursListe = ({ /> ))} -
- setCurrentPage(page)} - /> -
+ )} diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/PlansActionListe.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/PlansActionListe.tsx index 20d117ab3f..48715c41be 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/PlansActionListe.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/PlansActionListe.tsx @@ -188,15 +188,14 @@ const PlansActionListe = ({ /> ))} -
- setCurrentPage(page)} - /> -
+ )} diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ToutesLesFichesAction/FichesActionListe.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ToutesLesFichesAction/FichesActionListe.tsx index 2b46f54651..0754829b50 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ToutesLesFichesAction/FichesActionListe.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ToutesLesFichesAction/FichesActionListe.tsx @@ -353,15 +353,14 @@ const FichesActionListe = ({ /> ))} -
- setCurrentPage(page)} - /> -
+ )} diff --git a/packages/site/app/programme/annuaire/page.tsx b/packages/site/app/programme/annuaire/page.tsx index 04b0d0822d..011d79c449 100644 --- a/packages/site/app/programme/annuaire/page.tsx +++ b/packages/site/app/programme/annuaire/page.tsx @@ -60,7 +60,7 @@ const Annuaire = () => { nbOfElements={total} maxElementsPerPage={PAGINATION_LIMIT} idToScrollTo="annuaire-header" - onChange={(selectedPage) => setSelectPage(selectedPage)} + onChange={setSelectPage} /> ); diff --git a/packages/ui/src/design-system/Pagination/Pagination.tsx b/packages/ui/src/design-system/Pagination/Pagination.tsx index e1df51b805..a96dcf0736 100644 --- a/packages/ui/src/design-system/Pagination/Pagination.tsx +++ b/packages/ui/src/design-system/Pagination/Pagination.tsx @@ -33,7 +33,7 @@ export const Pagination = ({ const [nbOfPages, setNbOfPages] = useState( Math.ceil(nbOfElements / maxElementsPerPage) ); - const [pageButtons, setPageButtons] = useState([]); + const [pageButtons, setPageButtons] = useState<(number | undefined)[]>([]); const [currentPage, setCurrentPage] = useState(selectedPage); const [windowWidth, setWindowWidth] = useState(0); const [isMobile, setIsMobile] = useState(false); @@ -100,7 +100,7 @@ export const Pagination = ({ key={i} pageNumber={pageNum} isSelected={currentPage === pageNum} - onClick={() => handleChangePage(pageNum)} + onClick={() => !!pageNum && handleChangePage(pageNum)} /> ))} diff --git a/packages/ui/src/design-system/Pagination/utils.ts b/packages/ui/src/design-system/Pagination/utils.ts index 583f2b7d1d..adcfca9721 100644 --- a/packages/ui/src/design-system/Pagination/utils.ts +++ b/packages/ui/src/design-system/Pagination/utils.ts @@ -70,14 +70,15 @@ export const calculatePaginationArray = ({ : undefined; // Construction du tableau final - const finalArray = [...leftRange]; - if (!displayAllPages && leftIntersection !== undefined) { + const finalArray: (number | undefined)[] = [...leftRange]; + + if (!displayAllPages) { finalArray.push(leftIntersection); } finalArray.push(...middleRange); - if (isMiddlePage && !displayAllPages && rightIntersection !== undefined) { + if (isMiddlePage && !displayAllPages) { finalArray.push(rightIntersection); }