Skip to content

Pronina-People-table-advanced#1831

Open
ProninaMariia wants to merge 2 commits into
mate-academy:masterfrom
ProninaMariia:develop
Open

Pronina-People-table-advanced#1831
ProninaMariia wants to merge 2 commits into
mate-academy:masterfrom
ProninaMariia:develop

Conversation

@ProninaMariia

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 requesting changes because several core task requirements around filtering, sorting, and URL search params are not implemented yet, which means the solution does not fulfill the specified behavior. The People page currently loads and displays data correctly, but it does not read or apply query, sex, centuries, sort, or order from useSearchParams, so the people array is never filtered or sorted as required [CHECKLIST ITEM #1#3, #7#14]. Navigation within /people (Navbar People link and person links in the table) uses plain Link/NavLink without preserving search params, so any active filters or sorting are lost when you navigate, violating the requirement to keep state in the URL [CHECKLIST ITEM #4, #16]. Also, PeopleFilters is rendered unconditionally instead of only when people are successfully loaded and non-empty, which breaks the sidebar visibility rule [CHECKLIST ITEM #5].

The critical fixes you need are:

  • In PeoplePage.tsx, use useSearchParams to derive query, sex, centuries, sort, and order, compute a filtered & sorted visiblePeople array (case-insensitive name/mother/father filtering, multi-select centuries via getAll, sort by name/sex/born/died with the 3-click cycle), and pass visiblePeople to PeopleTable instead of raw people.
  • Gate rendering of PeopleFilters behind a condition like !loading && !error && people.length > 0 so the sidebar only appears after data is loaded.
  • Update navigation within the People section (Navbar People link and table/person links) to preserve the current search string, using a helper like SearchLink or to={{ pathname: '/people', search: location.search }} so filters and sort settings stay in the URL.
  • Refactor PeopleFilters (in its own file) to stop using static href hash links and instead use SearchLink/getSearchWith to update query, sex, and centuries search params.

Once these behaviors are wired up, your existing routing and table structure will nicely support the full feature set, and the app will align with all the checklist items. You already have a solid base (data loading, error handling, and routing), so focus on integrating the URL-driven filtering/sorting layer on top of it.


✨ 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 thread src/App.tsx
<h1 className="title">Home Page</h1>
<h1 className="title">Page not found</h1>
<PeoplePage />
<Routes>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Current routing works, but nothing here ensures that search params are preserved when navigating within /people (checklist #4/#16). When you later update links (e.g. People link in Navbar and person links in the table) to keep query/sort/centuries, make sure the router structure still supports that behavior.

Comment thread src/App.tsx
<Route
path="*"
element={<h1 className="title">Page not found</h1>}
/>

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 People nav link doesn’t preserve current search params, so navigating back to /people from a person page will reset filters and sorting, violating checklist items #4 and #16. Consider using your SearchLink or useSearchParams to keep the existing search in the URL for this link when already on the People section.

Comment thread src/components/Navbar.tsx Outdated
Comment on lines +26 to +27
<NavLink
to="/people"

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 requirements (#4, #16) specify that search params must be kept when navigating within the People page, but this NavLink always goes to /people without preserving any existing search string. Consider using a helper (like SearchLink with useSearchParams) or building the to with the current location.search so filters/sorting are not lost when clicking People in the navbar.

Comment thread src/components/Navbar.tsx
Comment on lines +35 to 36
</NavLink>
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PeopleFilters is rendered unconditionally, but checklist item #5 requires the sidebar with filters to appear only when people are loaded. You should gate this component behind !loading && !error && people.length > 0 (or equivalent) so it doesn’t render before data is available.

Comment on lines +14 to +17
setLoading(true);
getPeople()
.then(data => {
const peopleWithParents = data.map(person => ({

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 current routing setup correctly renders PeoplePage for both /people and /people/:slug, but it doesn’t address checklist items #4 and #16: search params must be kept when navigating within the People page. You’ll need to ensure links to /people and person details use search-aware navigation (via SearchLink) so query/sort/centuries params are preserved.

Comment thread src/components/PeopleTable.tsx Outdated
</th>

<th>Name</th>
<th>Sex</th>

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 /people/:slug route reuses PeoplePage, but you are not preserving search params when navigating to a specific person, nor passing any slug-based context into filtered/sorted state. Checklist items #3, #4, #16 require that filters and sort params are saved in URL search params and kept when navigating within the People page.

</tr>
</thead>

<tbody>

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 NavLink to /people does not preserve existing search params; according to checklist items #3, #4, and #16, navigation within the People page must keep the current filter/sort search parameters, so you likely need to use SearchLink or construct a to object with the current search.

Comment on lines +53 to +54
) : (
person.motherName || '-'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PeoplePage currently only loads and stores people; it does not read or apply any URL search params (query, sex, centuries, sort, order) to filter/sort the people before passing them to PeopleTable, which is required by several checklist items.

Comment thread src/components/PeopleTable.tsx Outdated
Comment on lines +18 to +21
<th>Name</th>
<th>Sex</th>
<th>Born</th>
<th>Died</th>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PeopleTable renders a static header; there is no UI or logic to handle sorting by name, sex, born, or died via clickable arrows in the th, nor is any sorting integrated with sort and order search params as described in checklist items #10#14 and #22#28.

Comment thread src/components/PeopleTable.tsx Outdated
Comment on lines +35 to +36
<Link
to={`/people/${person.slug}`}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All links in the table use simple to strings and ignore existing search parameters; per checklist items #3, #4, and #16, when selecting a person you must keep the current filter/sort search params, likely via SearchLink or manually including the current search in to.

@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

Your solution is approved because it fully meets the functional requirements for the advanced People Table task. Filtering, sorting, and navigation are all driven by URL search parameters (query, sex, centuries, sort, order), and the state is correctly restored on reload and when sharing URLs. The 3-step sorting cycle (ascending → descending → off) is implemented correctly, and when sorting is disabled, sort and order are removed from the URL as required. Navigation within the People section (including switching between list and details, and following person/mother/father links) preserves the current filters and sorting, which satisfies the “keep search params within /people” requirement. The sidebar only appears once people are successfully loaded and non-empty, and the filters behave correctly, including multi-century selection and removing query when the input is cleared. As a small optional improvement, you could consider using SearchLink consistently instead of manually concatenating ?${searchParams.toString()} in a few places to centralize URL-handling logic. Overall, this is a solid, well-structured implementation that aligns with the checklist and shows good understanding of URL-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

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.

2 participants