From b89cdd11defde3045d8679ebc6b0b36f432620c7 Mon Sep 17 00:00:00 2001 From: Nazar Date: Wed, 3 Jun 2026 21:15:33 +0300 Subject: [PATCH 1/4] Solution --- README.md | 2 +- src/App.scss | 4 + src/App.tsx | 24 +- .../CenturyFilter/CenturyFilter.tsx | 60 ++ src/components/CenturyFilter/index.ts | 1 + src/components/HomePage/HomePage.tsx | 3 + src/components/HomePage/index.ts | 1 + src/components/NameFilter/NameFilter.tsx | 26 + src/components/NameFilter/index.ts | 1 + src/components/Navbar/Navbar.tsx | 31 + src/components/Navbar/index.ts | 1 + src/components/NotFoundPage/NotFoundPage.tsx | 3 + src/components/NotFoundPage/index.ts | 1 + src/components/PeopleFilters.tsx | 77 +- src/components/PeoplePage/PeoplePage.tsx | 160 +++++ src/components/PeoplePage/index.ts | 1 + src/components/PeopleTable.tsx | 677 +++--------------- src/components/PeopleTable/index.ts | 1 + src/components/PersonLink/PersonLink.tsx | 14 + src/components/PersonLink/index.ts | 1 + .../PersonOfTable/PersonOfTable.tsx | 42 ++ src/components/PersonOfTable/index.ts | 1 + src/index.tsx | 6 +- tsconfig.json | 3 +- 24 files changed, 476 insertions(+), 665 deletions(-) create mode 100644 src/components/CenturyFilter/CenturyFilter.tsx create mode 100644 src/components/CenturyFilter/index.ts create mode 100644 src/components/HomePage/HomePage.tsx create mode 100644 src/components/HomePage/index.ts create mode 100644 src/components/NameFilter/NameFilter.tsx create mode 100644 src/components/NameFilter/index.ts create mode 100644 src/components/Navbar/Navbar.tsx create mode 100644 src/components/Navbar/index.ts create mode 100644 src/components/NotFoundPage/NotFoundPage.tsx create mode 100644 src/components/NotFoundPage/index.ts create mode 100644 src/components/PeoplePage/PeoplePage.tsx create mode 100644 src/components/PeoplePage/index.ts create mode 100644 src/components/PeopleTable/index.ts create mode 100644 src/components/PersonLink/PersonLink.tsx create mode 100644 src/components/PersonLink/index.ts create mode 100644 src/components/PersonOfTable/PersonOfTable.tsx create mode 100644 src/components/PersonOfTable/index.ts diff --git a/README.md b/README.md index 064a39440..fb020fddf 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://Palfinger2002.github.io/react_people-table-advanced/) and add it to the PR description. diff --git a/src/App.scss b/src/App.scss index c17d529f4..9708ec00e 100644 --- a/src/App.scss +++ b/src/App.scss @@ -1,3 +1,7 @@ iframe { display: none; } + +h1 { + margin-top: 52px; +} diff --git a/src/App.tsx b/src/App.tsx index adcb8594e..6d28a7c0f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,18 +1,28 @@ -import { PeoplePage } from './components/PeoplePage'; -import { Navbar } from './components/Navbar'; - import './App.scss'; +import { Navbar } from './components/Navbar'; +import { HomePage } from './components/HomePage/HomePage'; +import { PeoplePage } from './components/PeoplePage/PeoplePage'; +import { Navigate, Route, Routes } from 'react-router-dom'; +import { NotFoundPage } from './components/NotFoundPage'; -export const App = () => { +export const App: React.FC = () => { return (
-

Home Page

-

Page not found

- + + } /> + + + } /> + } /> + + + } /> + } /> +
diff --git a/src/components/CenturyFilter/CenturyFilter.tsx b/src/components/CenturyFilter/CenturyFilter.tsx new file mode 100644 index 000000000..def6d05c5 --- /dev/null +++ b/src/components/CenturyFilter/CenturyFilter.tsx @@ -0,0 +1,60 @@ +import classNames from 'classnames'; +import { useSearchParams } from 'react-router-dom'; + +export const CenturyFilter = () => { + const [searchParams, setSearchParams] = useSearchParams(); + + const CENTURIES = ['16', '17', '18', '19', '20']; + const values = searchParams.getAll('centuries'); + + return ( +
+ + + +
+ ); +}; diff --git a/src/components/CenturyFilter/index.ts b/src/components/CenturyFilter/index.ts new file mode 100644 index 000000000..bf10644f6 --- /dev/null +++ b/src/components/CenturyFilter/index.ts @@ -0,0 +1 @@ +export * from './CenturyFilter'; diff --git a/src/components/HomePage/HomePage.tsx b/src/components/HomePage/HomePage.tsx new file mode 100644 index 000000000..e4cd51ac5 --- /dev/null +++ b/src/components/HomePage/HomePage.tsx @@ -0,0 +1,3 @@ +export const HomePage = () => { + return

Home Page

; +}; diff --git a/src/components/HomePage/index.ts b/src/components/HomePage/index.ts new file mode 100644 index 000000000..11e53da67 --- /dev/null +++ b/src/components/HomePage/index.ts @@ -0,0 +1 @@ +export * from './HomePage'; diff --git a/src/components/NameFilter/NameFilter.tsx b/src/components/NameFilter/NameFilter.tsx new file mode 100644 index 000000000..40fb13959 --- /dev/null +++ b/src/components/NameFilter/NameFilter.tsx @@ -0,0 +1,26 @@ +import { useSearchParams } from 'react-router-dom'; + +export const NameFilter = () => { + const [searchParams, setSearchParams] = useSearchParams(); + const query = searchParams.get('query') || ''; + + return ( + { + const value = event.target.value; + + if (value === '') { + searchParams.delete('query'); + setSearchParams(searchParams); + } else { + setSearchParams({ query: value }); + } + }} + /> + ); +}; diff --git a/src/components/NameFilter/index.ts b/src/components/NameFilter/index.ts new file mode 100644 index 000000000..844e198b0 --- /dev/null +++ b/src/components/NameFilter/index.ts @@ -0,0 +1 @@ +export * from './NameFilter'; diff --git a/src/components/Navbar/Navbar.tsx b/src/components/Navbar/Navbar.tsx new file mode 100644 index 000000000..a18e6ad58 --- /dev/null +++ b/src/components/Navbar/Navbar.tsx @@ -0,0 +1,31 @@ +import classNames from 'classnames'; +import { NavLink } from 'react-router-dom'; + +const getLinkClass = ({ isActive }: { isActive: boolean }) => { + return classNames('navbar-item', { + 'has-background-grey-lighter': isActive, + }); +}; + +export const Navbar: React.FC = () => { + return ( + + ); +}; diff --git a/src/components/Navbar/index.ts b/src/components/Navbar/index.ts new file mode 100644 index 000000000..e8a656233 --- /dev/null +++ b/src/components/Navbar/index.ts @@ -0,0 +1 @@ +export * from './Navbar'; diff --git a/src/components/NotFoundPage/NotFoundPage.tsx b/src/components/NotFoundPage/NotFoundPage.tsx new file mode 100644 index 000000000..87fe719a7 --- /dev/null +++ b/src/components/NotFoundPage/NotFoundPage.tsx @@ -0,0 +1,3 @@ +export const NotFoundPage = () => { + return

Page not found

; +}; diff --git a/src/components/NotFoundPage/index.ts b/src/components/NotFoundPage/index.ts new file mode 100644 index 000000000..6197aa75a --- /dev/null +++ b/src/components/NotFoundPage/index.ts @@ -0,0 +1 @@ +export * from './NotFoundPage'; diff --git a/src/components/PeopleFilters.tsx b/src/components/PeopleFilters.tsx index c9c819cd3..2f46c08fc 100644 --- a/src/components/PeopleFilters.tsx +++ b/src/components/PeopleFilters.tsx @@ -1,28 +1,33 @@ +import { NameFilter } from './NameFilter'; +import { CenturyFilter } from './CenturyFilter'; +import { useSearchParams } from 'react-router-dom'; + export const PeopleFilters = () => { + const [searchParams] = useSearchParams(); + const sex = searchParams.get('sex'); + return (