From 8de95d38ec359214c05e46bf1f4482815576537e Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 21 Jun 2026 20:41:00 +0300 Subject: [PATCH 1/2] add solution --- README.md | 2 +- index.html | 25 +- package-lock.json | 9 +- package.json | 2 +- src/App.tsx | 37 +- src/components/Layout/Layout.tsx | 15 + src/components/Layout/index.tsx | 1 + src/components/Navbar.tsx | 26 - src/components/Navigation/Navigation.tsx | 32 + src/components/Navigation/index.tsx | 1 + src/components/PeopleFilters.tsx | 96 --- .../PeopleFilters/PeopleFilters.tsx | 114 ++++ src/components/PeopleFilters/index.tsx | 1 + src/components/PeoplePage.tsx | 33 - src/components/PeopleTable.tsx | 645 ------------------ src/components/PersonLink/PersonLink.tsx | 30 + src/components/PersonLink/index.tsx | 1 + src/components/SortIcon.tsx | 28 + src/pages/HomePage.tsx | 3 + src/pages/NotFoundPage.tsx | 3 + src/pages/PeoplePage.tsx | 227 ++++++ 21 files changed, 497 insertions(+), 834 deletions(-) create mode 100644 src/components/Layout/Layout.tsx create mode 100644 src/components/Layout/index.tsx delete mode 100644 src/components/Navbar.tsx create mode 100644 src/components/Navigation/Navigation.tsx create mode 100644 src/components/Navigation/index.tsx delete mode 100644 src/components/PeopleFilters.tsx create mode 100644 src/components/PeopleFilters/PeopleFilters.tsx create mode 100644 src/components/PeopleFilters/index.tsx delete mode 100644 src/components/PeoplePage.tsx delete mode 100644 src/components/PeopleTable.tsx create mode 100644 src/components/PersonLink/PersonLink.tsx create mode 100644 src/components/PersonLink/index.tsx create mode 100644 src/components/SortIcon.tsx create mode 100644 src/pages/HomePage.tsx create mode 100644 src/pages/NotFoundPage.tsx create mode 100644 src/pages/PeoplePage.tsx diff --git a/README.md b/README.md index 064a39440..36f7981f6 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://MaxShaggy.github.io/react_people-table-advanced/) and add it to the PR description. diff --git a/index.html b/index.html index 095fb3a45..290bace89 100644 --- a/index.html +++ b/index.html @@ -1,12 +1,15 @@ - - - - - Vite + React + TS - - -
- - - + + + + + + Vite + React + TS + + + +
+ + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index df276ce8a..a2d822adb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ }, "devDependencies": { "@cypress/react18": "^2.0.1", - "@mate-academy/scripts": "^1.9.12", + "@mate-academy/scripts": "^2.1.3", "@mate-academy/students-ts-config": "*", "@mate-academy/stylelint-config": "*", "@types/node": "^20.14.10", @@ -1184,10 +1184,11 @@ } }, "node_modules/@mate-academy/scripts": { - "version": "1.9.12", - "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-1.9.12.tgz", - "integrity": "sha512-/OcmxMa34lYLFlGx7Ig926W1U1qjrnXbjFJ2TzUcDaLmED+A5se652NcWwGOidXRuMAOYLPU2jNYBEkKyXrFJA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-2.1.3.tgz", + "integrity": "sha512-a07wHTj/1QUK2Aac5zHad+sGw4rIvcNl5lJmJpAD7OxeSbnCdyI6RXUHwXhjF5MaVo9YHrJ0xVahyERS2IIyBQ==", "dev": true, + "license": "MIT", "dependencies": { "@octokit/rest": "^17.11.2", "@types/get-port": "^4.2.0", diff --git a/package.json b/package.json index 919fbd42b..77fc93ccf 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ }, "devDependencies": { "@cypress/react18": "^2.0.1", - "@mate-academy/scripts": "^1.9.12", + "@mate-academy/scripts": "^2.1.3", "@mate-academy/students-ts-config": "*", "@mate-academy/stylelint-config": "*", "@types/node": "^20.14.10", diff --git a/src/App.tsx b/src/App.tsx index adcb8594e..13615ee47 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,20 +1,23 @@ -import { PeoplePage } from './components/PeoplePage'; -import { Navbar } from './components/Navbar'; +import { Routes, Route, Navigate } from 'react-router-dom'; import './App.scss'; +import { HomePage } from './pages/HomePage'; +import { NotFoundPage } from './pages/NotFoundPage'; +import { PeoplePage } from './pages/PeoplePage'; +import { Layout } from './components/Layout'; -export const App = () => { - return ( -
- - -
-
-

Home Page

-

Page not found

- -
-
-
- ); -}; +export const App = () => ( +
+ + }> + } /> + + } /> + } /> + + } /> + } /> + + +
+); diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx new file mode 100644 index 000000000..dae11131e --- /dev/null +++ b/src/components/Layout/Layout.tsx @@ -0,0 +1,15 @@ +import { Outlet } from 'react-router-dom'; +import { Navigation } from '../Navigation'; + +export function Layout() { + return ( + <> + +
+
+ +
+
+ + ); +} diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx new file mode 100644 index 000000000..9877e7f4a --- /dev/null +++ b/src/components/Layout/index.tsx @@ -0,0 +1 @@ +export * from './Layout'; diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx deleted file mode 100644 index 3f63898b2..000000000 --- a/src/components/Navbar.tsx +++ /dev/null @@ -1,26 +0,0 @@ -export const Navbar = () => { - return ( - - ); -}; diff --git a/src/components/Navigation/Navigation.tsx b/src/components/Navigation/Navigation.tsx new file mode 100644 index 000000000..12687fe47 --- /dev/null +++ b/src/components/Navigation/Navigation.tsx @@ -0,0 +1,32 @@ +import { Link, useLocation } from 'react-router-dom'; + +export function Navigation() { + const { pathname } = useLocation(); + + return ( + + ); +} diff --git a/src/components/Navigation/index.tsx b/src/components/Navigation/index.tsx new file mode 100644 index 000000000..95e14a93f --- /dev/null +++ b/src/components/Navigation/index.tsx @@ -0,0 +1 @@ +export * from './Navigation'; diff --git a/src/components/PeopleFilters.tsx b/src/components/PeopleFilters.tsx deleted file mode 100644 index c9c819cd3..000000000 --- a/src/components/PeopleFilters.tsx +++ /dev/null @@ -1,96 +0,0 @@ -export const PeopleFilters = () => { - return ( -