Skip to content

Develop#1420

Open
redfield-mp wants to merge 4 commits intomate-academy:masterfrom
redfield-mp:develop
Open

Develop#1420
redfield-mp wants to merge 4 commits intomate-academy:masterfrom
redfield-mp:develop

Conversation

@redfield-mp
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

This is a great start, and the core pagination logic is working correctly! However, a few changes are needed to meet all the task requirements.

The most important missing piece is synchronizing the pagination state with the URL. In src/App.tsx, please use query parameters (e.g., ?page=2&perPage=10) to manage the page and perPage state. This is a key requirement that allows users to bookmark and share links. The useSearchParams hook from react-router-dom is a great tool for this.

Additionally, in src/components/Pagination/Pagination.tsx, the currentPage prop should be optional with a default value of 1 as specified. You can update its type to currentPage?: number; and set the default in the component's props.

You're very close to a complete solution!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines 7 to 14
currentPage: number;
onPageChange: (page: number) => void;
};

export const Pagination = ({
total,
perPage,
currentPage,

Choose a reason for hiding this comment

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

The task description specifies that the currentPage prop should be optional with a default value of 1. Currently, it's defined as a required prop. You should make it optional in the Props type (e.g., currentPage?: number;) and provide a default value in the component's signature.

key={n}
className={cn('page-item', {
active: currentPage === n,
disabled: n === currentPage,

Choose a reason for hiding this comment

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

The requirements state that the current page's li element should have the active class, which you've correctly implemented. However, adding the disabled class here is not specified in the task and is redundant, as the click handler already prevents action on the current page.

Copy link
Author

Choose a reason for hiding this comment

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

Це ж додано, щоб візуально виділити не клікабельний стан

Comment on lines +10 to +11
const [currentPage, setCurrentPage] = React.useState(1);
const [perPage, setPerPage] = React.useState(5);

Choose a reason for hiding this comment

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

The task requires using React Router to manage the page and perPage values in the URL. Currently, the state is initialized with static values. You should read these values from the URL's query parameters on page load to properly apply them.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Good progress on the components! However, a couple of key requirements are still missing, so changes are needed before this can be approved.

The most critical issue is that the application state is not synchronized with the URL. The page and perPage values must be managed using URL query parameters (e.g., ?page=2&perPage=5) so the state can be bookmarked and shared. Please use the useSearchParams hook from react-router-dom in src/App.tsx to implement this.

Additionally, in src/components/Pagination/Pagination.tsx, the optional currentPage prop needs a default value of 1. You can set this directly in the component's props destructuring, like ({ currentPage = 1, ...props }).

Addressing these two points will complete the requirements. You're very close!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines 11 to 16
export const Pagination = ({
total,
perPage,
currentPage,
onPageChange,
}: Props) => {

Choose a reason for hiding this comment

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

Excellent work on making the currentPage prop optional in the type definition. To fully meet the requirement (currentPage={1} /* optional with 1 by default */), you also need to provide a default value of 1. You can easily set this up during prop destructuring, like currentPage = 1.

Comment on lines +10 to +11
const [currentPage, setCurrentPage] = React.useState(1);
const [perPage, setPerPage] = React.useState(5);

Choose a reason for hiding this comment

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

The task requires synchronizing the page and perPage state with the URL using query parameters (e.g., ?page=2&perPage=5). Currently, you're using local component state with useState, which doesn't persist in the URL. Please use the useSearchParams hook from react-router-dom to read the initial state from the URL and to update it when the page or per-page value changes.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great job fixing the Pagination component and correctly setting the default prop value!

I am approving this submission as an educational override to help you move forward, but the most critical requirement from the previous review has not yet been addressed. The application's state for page and perPage must be managed through URL query parameters, not local useState.

In src/App.tsx, please replace the useState hooks for currentPage and perPage with the useSearchParams hook from react-router-dom. This will ensure the application's state can be bookmarked and shared, which is a key requirement of the task. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment on lines +10 to +11
const [currentPage, setCurrentPage] = React.useState(1);
const [perPage, setPerPage] = React.useState(5);

Choose a reason for hiding this comment

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

According to the task requirements, the currentPage and perPage values should be managed through URL query parameters, not local component state. Please use the useSearchParams hook from react-router-dom to read these values from the URL on load and to update the URL when they change.

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