From ae215d09ca42608410c916c574120057f8835547 Mon Sep 17 00:00:00 2001 From: Valentyna Date: Wed, 10 Jun 2026 15:12:44 +0300 Subject: [PATCH 1/2] People Table app with routing, filters and sorting --- README.md | 2 +- src/App.tsx | 22 +- src/components/Navbar.tsx | 26 +- src/components/PeopleFilters.tsx | 61 ++- src/components/PeoplePage.tsx | 112 ++++- src/components/PeopleTable.tsx | 700 +++++-------------------------- src/components/PersonLink.tsx | 22 + src/index.tsx | 6 +- src/pages/HomePage.tsx | 3 + src/pages/NotFoundPage.tsx | 3 + 10 files changed, 307 insertions(+), 650 deletions(-) create mode 100644 src/components/PersonLink.tsx create mode 100644 src/pages/HomePage.tsx create mode 100644 src/pages/NotFoundPage.tsx diff --git a/README.md b/README.md index 064a39440..73ba6564c 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ implement the ability to filter and sort people in the table. - Implement a solution following the [React task guideline](https://github.com/mate-academy/react_task-guideline#react-tasks-guideline). - Use the [React TypeScript cheat sheet](https://mate-academy.github.io/fe-program/js/extra/react-typescript). - Open one more terminal and run tests with `npm test` to ensure your solution is correct. -- Replace `` with your Github username in the [DEMO LINK](https://.github.io/react_people-table-advanced/) and add it to the PR description. +- Replace `` with your Github username in the [DEMO LINK](https://ValyaMeln.github.io/react_people-table-advanced/) and add it to the PR description. diff --git a/src/App.tsx b/src/App.tsx index adcb8594e..0e850e9f5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,11 @@ +import { Routes, Route, Navigate } from 'react-router-dom'; + import { PeoplePage } from './components/PeoplePage'; import { Navbar } from './components/Navbar'; import './App.scss'; +import { HomePage } from './pages/HomePage'; +import { NotFoundPage } from './pages/NotFoundPage'; export const App = () => { return ( @@ -10,9 +14,21 @@ export const App = () => {
-

Home Page

-

Page not found

- + + } /> + + } /> + + + } /> + } /> + + + } /> + + {/*

Home Page

+

Page not found

*/} + {/* */}
diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 3f63898b2..5811b80aa 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,3 +1,5 @@ +import { NavLink } from 'react-router-dom'; + export const Navbar = () => { return ( diff --git a/src/components/PeopleFilters.tsx b/src/components/PeopleFilters.tsx index c9c819cd3..e08e79fc8 100644 --- a/src/components/PeopleFilters.tsx +++ b/src/components/PeopleFilters.tsx @@ -1,4 +1,12 @@ +import { useSearchParams } from 'react-router-dom'; +import { SearchLink } from './SearchLink'; + export const PeopleFilters = () => { + const [searchParams] = useSearchParams(); + + const selected = searchParams.getAll('centuries'); + const centuries = ['16', '17', '18', '19', '20']; + return ( ); diff --git a/src/components/PeoplePage.tsx b/src/components/PeoplePage.tsx index cd4270b3a..3fad1b938 100644 --- a/src/components/PeoplePage.tsx +++ b/src/components/PeoplePage.tsx @@ -78,9 +78,9 @@ export const PeoplePage = () => { return order === 'desc' ? -res : res; }); - if (order === 'desc') { - result.reverse(); - } + // if (order === 'desc') { + // result.reverse(); + // } } return result;