Skip to content

Commit

Permalink
Add totalCount prop for server side pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
DysphoricUnicorn committed Dec 4, 2024
1 parent c3fb027 commit dea32cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/js/components/ButterflyMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down Expand Up @@ -185,7 +185,7 @@ const ButterflyMap = (props: ButterflyMapProps) => {
handlePoiClick={handlePoiClick}
entriesPerPage={props.entriesPerPage}
setEntriesPerPage={props.setEntriesPerPage}
/>}
totalCount={props.totalCount}/>}
</ThemeProvider>;
};

Expand All @@ -202,6 +202,7 @@ type ButterflyMapProps = {
setEntriesPerPage?: React.Dispatch<React.SetStateAction<number>>,
paginationPage?: number,
setPaginationPage?: React.Dispatch<React.SetStateAction<number>>,
totalCount?: number,
}

export default ButterflyMap;
3 changes: 2 additions & 1 deletion src/js/components/PointBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type PointBarProps = {
localStrings: LocalStrings,
entriesPerPage?: number,
setEntriesPerPage?: React.Dispatch<React.SetStateAction<number>>,
totalCount?: number,
}

const PointBar = (props: PointBarProps) => {
Expand Down Expand Up @@ -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}/>
</>;
};
Expand Down

0 comments on commit dea32cb

Please sign in to comment.