Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIEH-1141: Pagination investigate #1382

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/components/query-search-list/query-search-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,33 @@ const QuerySearchList = ({
if (!length) {
return notFoundMessage;
}

/**
* main function for paggination
* now it's working for prev next buttons
* in commented code functionality for load more button
* which is already emplemented and working correctly
*/
const getLoadMoreButton = () => {
const isUnloadedPagesPresent = (totalLength !== length) && !(length % PAGE_SIZE);

return (
<>
<Button
disabled={page === 1} // for first page prev button should be disabled
onClick={() => { setPage(page - 1); }}
>
prev
</Button>
{/* place for page counter */}
<Button
disabled={isUnloadedPagesPresent} // for the last page it should be disabled
onClick={() => { setPage(page + 1); }}
>
next
</Button>
</>
);
/*
if (isUnloadedPagesPresent) {
return (
<div className={styles['button-wrapper']}>
Expand All @@ -71,6 +94,7 @@ const QuerySearchList = ({
}

return null;
*/
};

return (
Expand Down
3 changes: 2 additions & 1 deletion src/redux/reducers/packageTitles.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const handlers = {
isLoading: false,
hasLoaded: true,
hasFailed: false,
items: [...state.items, ...payload.data],
// just one change, it is set new collection to state after each *next-prev* click
items: [...payload.data],
totalResults: payload.totalResults,
}),
[GET_PACKAGE_TITLES_FAILURE]: (state, action) => ({
Expand Down