From dea32cb5d28d74bb66addbf309c568d188a438dd Mon Sep 17 00:00:00 2001 From: Jennifer Kirsch Date: Wed, 4 Dec 2024 15:20:37 +0100 Subject: [PATCH] Add totalCount prop for server side pagination --- src/js/components/ButterflyMap.tsx | 5 +++-- src/js/components/PointBar.tsx | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/components/ButterflyMap.tsx b/src/js/components/ButterflyMap.tsx index a0d43e6..88147f2 100644 --- a/src/js/components/ButterflyMap.tsx +++ b/src/js/components/ButterflyMap.tsx @@ -42,7 +42,7 @@ const ButterflyMap = (props: ButterflyMapProps) => { React.useEffect(() => { let found = props.paginationPage === undefined; - for (const serverSideField of [props.setPaginationPage, props.entriesPerPage, props.setEntriesPerPage]) { + for (const serverSideField of [props.setPaginationPage, props.entriesPerPage, props.setEntriesPerPage, props.totalCount]) { if ((serverSideField === undefined) !== found) { throw new Error('react butterfly map error: When one of the server side pagination props is set, all of them have to be.'); } @@ -185,7 +185,7 @@ const ButterflyMap = (props: ButterflyMapProps) => { handlePoiClick={handlePoiClick} entriesPerPage={props.entriesPerPage} setEntriesPerPage={props.setEntriesPerPage} - />} + totalCount={props.totalCount}/>} ; }; @@ -202,6 +202,7 @@ type ButterflyMapProps = { setEntriesPerPage?: React.Dispatch>, paginationPage?: number, setPaginationPage?: React.Dispatch>, + totalCount?: number, } export default ButterflyMap; diff --git a/src/js/components/PointBar.tsx b/src/js/components/PointBar.tsx index 6273767..5286e3c 100644 --- a/src/js/components/PointBar.tsx +++ b/src/js/components/PointBar.tsx @@ -22,6 +22,7 @@ type PointBarProps = { localStrings: LocalStrings, entriesPerPage?: number, setEntriesPerPage?: React.Dispatch>, + totalCount?: number, } const PointBar = (props: PointBarProps) => { @@ -60,7 +61,7 @@ const PointBar = (props: PointBarProps) => { setPage={setPage} entriesPerPage={props.entriesPerPage ?? entriesPerPage} setEntriesPerPage={props.setEntriesPerPage ?? setEntriesPerPage} - entryCount={displayPoints.length} + entryCount={props.totalCount ?? displayPoints.length} localStrings={localStrings}/> ; };