Skip to content

Added filtering and sorting with searchParams#1833

Open
RVDotsenko wants to merge 3 commits into
mate-academy:masterfrom
RVDotsenko:feat/filtering-sorting
Open

Added filtering and sorting with searchParams#1833
RVDotsenko wants to merge 3 commits into
mate-academy:masterfrom
RVDotsenko:feat/filtering-sorting

Conversation

@RVDotsenko

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 there are still a few requirement-level issues that affect core functionality. First, the Navbar People link and the "Reset all filters" link in PeopleFilters.tsx both navigate to /people without preserving existing search params, which violates the requirement that navigation within the People page must keep URL search params so filters and sort state are preserved [CHECKLIST ITEM #3]. You can fix this by deriving the current location.search or using SearchLink/setSearchParams to either keep the current search string or explicitly clear only the filter-related params while staying on the same pathname.

Second, the PeopleTable headers for Mother and Father are still wrapped in SearchLink, so clicking them sets sort=mother or sort=father, even though the task only allows sorting by name, sex, born, and died [CHECKLIST ITEM #9]. This can produce invalid sort keys for sortPeople, so those columns should not be sortable at all (skip SearchLink and sort-param changes for them). Third, PeoplePage renders PeopleFilters whenever isLoading is false, even if there is a loading error, a “no people” error, or an empty list; the requirement says the filters sidebar should appear only when people are successfully loaded [CHECKLIST ITEM #4], so you should gate PeopleFilters with conditions like !errors.loading && !errors.people && people.length > 0. Once you address these points, the rest of your filtering, sorting, and URL search-param logic looks solid, and your solution will align well with the advanced table requirements.


✨ 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/components/Navbar.tsx Outdated
Comment on lines +24 to +29
<NavLink
aria-current="page"
className="navbar-item has-background-grey-lighter"
href="#/people"
className={({ isActive }) =>
cn('navbar-item', { 'has-background-grey-lighter': isActive })
}
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.

Current People NavLink always navigates to /people and discards any existing search params, which violates checklist item #3 about keeping search params when navigating within the People page. Consider using useLocation or useSearchParams and generating a to that includes the existing search string so the filters/sort state are preserved when clicking this link.

Comment thread src/components/PeopleFilters.tsx Outdated

<div className="panel-block">
<a className="button is-link is-outlined is-fullwidth" href="#/people">
<Link className="button is-link is-outlined is-fullwidth" 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.

Using a plain Link to /people for "Reset all filters" drops all existing search params, which conflicts with checklist item #3 (search params must be preserved when navigating within the People page). Consider resetting filters by updating search params (e.g. via SearchLink or setSearchParams with cleared values) while keeping the same pathname rather than hard-navigating to /people.

Comment on lines +55 to +79
{columnNames.map(columnName => {
const normalizedColumnName = columnName.toLowerCase();

const searchParam =
search.sort === normalizedColumnName
? search.order === 'desc'
? { sort: null, order: null }
: { sort: normalizedColumnName, order: 'desc' }
: { sort: normalizedColumnName, order: null };

return (
<th key={columnName}>
<span className="is-flex is-flex-wrap-nowrap">
{columnName}
<SearchLink params={searchParam}>
{
<SortIcon
columnName={columnName}
currentSort={search.sort}
currentOrder={search.order}
/>
}
</SearchLink>
</span>
</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.

Although SortIcon returns null for Mother/Father, this header still wraps SearchLink using normalizedColumnName, so clicking those headers will set sort to mother or father. The requirements only specify sorting by name, sex, born, and died (checklist item #9). Consider skipping SearchLink and any sort-param changes for Mother and Father columns so they are not sortable.

Comment thread src/pages/PeoplePage.tsx Outdated
Comment on lines +58 to +59
<div className="column is-7-tablet is-narrow-desktop">
{isLoading ? <Loader /> : <PeopleFilters />}

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 requirement says the filters sidebar should appear only when people are loaded. Here PeopleFilters is rendered whenever isLoading is false, even if errors.people or errors.loading is true or people is empty. Consider adding conditions (e.g., !errors.loading && !errors.people && people.length > 0) so filters are only shown when the data has successfully loaded.

@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 correctly implements all of the critical filtering, sorting, and URL search-parameter behaviors required by the advanced people table task. The table uses the shared filterPeople and sortPeople utilities, encodes filters and sort state into URL search params via SearchLink, getSearchWith, and useProjectParams, and preserves search params when navigating within the People page (including the navbar People link and person selection). The Name filter updates and removes the query param appropriately and performs case-insensitive matching against name, mother, and father as required, while the Century filter supports multiple selections, an “All” option, and uses append/getAll for the centuries param. Sorting is correctly limited to Name, Sex, Born, and Died, with the three-step cycle (ascending → descending → disabled) wired through sort and order=desc, and Mother/Father headers are non-sortable. The sidebar filters appear only when people are successfully loaded, and error and loading states are handled without breaking functionality. As minor, non-blocking polish, you could simplify a few comments, make the sort-order flag naming more expressive, and ensure you’ve run npm test, but these do not affect task completion—overall this is a solid, requirement-compliant implementation.


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

Footnotes

  1. Rate AI review example

@vadiimvooo vadiimvooo 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.

Awesome 🔥

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.

4 participants