Skip to content

add task solution#1517

Open
nkoropka wants to merge 1 commit into
mate-academy:masterfrom
nkoropka:develop
Open

add task solution#1517
nkoropka wants to merge 1 commit into
mate-academy:masterfrom
nkoropka:develop

Conversation

@nkoropka

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am approving your solution because all core functional requirements of the pagination task are correctly implemented and there are no critical blockers. The Pagination component is stateless, pages are calculated correctly, only current-page items are rendered, prev/next links work with proper disabled and aria-disabled handling, and URL sync via HashRouter + useSearchParams behaves as required. The info text format and data-cy attributes match the specification for the 42-item scenario the task is built around, and the per-page selector has the correct options and resets to page 1 on change.

The remaining points are minor improvements rather than blockers: the special-case info text for the zero-items case uses items 0 - 0 of 0 instead of the usual 1-based pattern, and currentPage is typed as required while you also try to default it to 1 in destructuring. If you iterate further, you could either remove the unused totalItems === 0 branch (since the task always uses 42 items) or make its format consistent with the main pattern, and adjust the Props type to currentPage?: number if you want to keep the internal default. Overall, this is a solid, well-structured implementation that demonstrates good understanding of stateless components, pagination logic, and router-based state management.


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

Footnotes

  1. Rate AI review example

Comment thread src/App.tsx
Comment on lines +40 to +43
const infoText =
totalItems > 0
? `Page ${currentPage} (items ${startItemIndex + 1} - ${endItemIndex} of ${totalItems})`
: `Page 1 (items 0 - 0 of 0)`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The fallback string for infoText (Page 1 (items 0 - 0 of 0)) does not match the format implied by the task and by the normal branch (which uses items start - end of total). Given the fixed 42 items in this task, you can simplify by removing the special case and always using the main format logic based on totalItems.

Comment thread src/App.tsx
Comment on lines 7 to +14
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const items = getNumbers(1, 42).map(n => `Item ${n}`);

export const App: React.FC = () => {
const [searchParams, setSearchParams] = useSearchParams();

const currentPage = Number(searchParams.get('page')) || 1;
const perPage = Number(searchParams.get('perPage')) || 5;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You’re assigning a default currentPage = 1 here while the prop is declared as required (currentPage: number) in Props. According to the requirements, currentPage should be optional with 1 by default, so consider making currentPage?: number in Props and then safely default it inside the component, or default it in the parent and keep the prop required.

data-cy="prevLink"
className="page-link"
href="#prev"
aria-disabled={isFirstPage}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For the empty-items case you render Page 1 (items 0 - 0 of 0), which deviates from the normal 1-based indexing pattern (items 1 - 5 of 42) described in the task; ensure this special-case format matches what the tests expect or adjust it to be consistent with the spec.

@etojeDenys etojeDenys left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good job

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