Skip to content

feat: Added Pagination to the Resources Page #166

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

Merged
merged 3 commits into from
Nov 1, 2020

Conversation

pdotsani
Copy link
Contributor

@pdotsani pdotsani commented Oct 17, 2020

What type of PR is this? (check all applicable)

  • ♻️ Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🎨 Enhancement
  • 📝 Documentation Update
  • 🔖 Release
  • 🚩 Other

Context

Closes issue #104

Screenshots/Recordings (if there are UI changes)

Screen Shot 2020-10-17 at 10 01 51 AM

Implementation Details - what was your thought process as you changed the code?

  • Modified query to toggle between pagination and search.
  • Added Pagination component from material UI lab library.

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation (readme.md or contributing.md)?

  • 📜 readme.md
  • 📜 contributing.md
  • 🙅 no documentation needed
  • 🙋 I'd like someone to help write documentation, and will file a new issue for it

@pdotsani pdotsani marked this pull request as draft October 17, 2020 17:20
@lpatmo
Copy link
Member

lpatmo commented Oct 20, 2020

YAY thank you for putting up this draft, @pdotsani! Do you need help getting the merge conflicts fixed?

Separately, I'll tag this as hacktoberfest-accepted in case you'd like the credit.

@lpatmo
Copy link
Member

lpatmo commented Oct 20, 2020

Also, I won't review this until this is out of draft mode.

@pdotsani pdotsani force-pushed the feature/resources-pagination branch from 16f459b to 02c291c Compare October 20, 2020 15:16
@pdotsani pdotsani marked this pull request as ready for review October 20, 2020 15:17
@pdotsani pdotsani force-pushed the feature/resources-pagination branch from 02c291c to 4c54a76 Compare October 20, 2020 15:20
@pdotsani
Copy link
Contributor Author

pdotsani commented Oct 20, 2020

@lpatmo Looks like a rebase fixed all the conflicts. Should be good for a review.

@@ -0,0 +1,95 @@
import React, { useState } from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file can be removed in favor of src/pages/Resources/Resources.js, right?

getResources
);
const [goToPage, setGoToPage] = useState();
const [isPagination, triggerPagination] = useState();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was tempted to ask that this be renamed paginate, setPaginate for consistency's sake, but triggerPagination has a certain ring to it 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, thinking we should initialize the value to be null: useState();

@@ -58,6 +67,18 @@ function Resources() {
</Typography>
)}
<br />
<Pagination
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also hide the pagination UI when there is a searchValue?

That way we won't see something like this:
image

That "1" is clickable, leading to this UI which doesn't make sense:
image

@@ -58,6 +67,18 @@ function Resources() {
</Typography>
)}
<br />
<Pagination
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI nitpick: what do you think about moving the pagination component to the bottom of the grid? :)

@lpatmo
Copy link
Member

lpatmo commented Oct 21, 2020

🎉 Functionality works and you've figured out how to work with https://material-ui.com/components/pagination/, which is great!

Left a few comments re: minor details like:

  • moving the component below the results
  • naming convention questions re: the isPagination, triggerPagination variable
  • hiding the pagination component when search is in effect, so it won't be clickable -> cause confusion for users

Thanks @pdotsani! Happy to discuss more in threads if you want to push back or have questions

Comment on lines 15 to 21
let params;

if (isPagination) {
params = `?page=${goToPage}`;
} else {
params = `?search=${searchValue}`;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let params;
if (isPagination) {
params = `?page=${goToPage}`;
} else {
params = `?search=${searchValue}`;
}
const params = isPagination? `?page=${goToPage}` : `?search=${searchValue}`;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, @turretd!

…agination component when there is no search term, and moved it down on the page
@lpatmo lpatmo merged commit 02eac58 into main Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants