diff --git a/README.md b/README.md index 24519caab..5c3a42959 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://serkrops.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..d8117c7fe 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,20 +1,14 @@ -import { PeoplePage } from './components/PeoplePage'; -import { Navbar } from './components/Navbar'; - import './App.scss'; +import { Outlet } from 'react-router-dom'; +import { Navbar } from './components/Navbar'; -export const App = () => { - return ( -
- - -
-
-

Home Page

-

Page not found

- -
+export const App = () => ( +
+ +
+
+
-
- ); -}; + +
+); diff --git a/src/Root.tsx b/src/Root.tsx new file mode 100644 index 000000000..fbb008a25 --- /dev/null +++ b/src/Root.tsx @@ -0,0 +1,25 @@ +import { + Navigate, + Route, + HashRouter as Router, + Routes, +} from 'react-router-dom'; +import { App } from './App'; +import { NotFoundPage } from './components/NotFoundPage'; +import { PeoplePage } from './components/PeoplePage'; +import { HomePage } from './components/HomePage'; + +export const Root = () => ( + + + }> + } /> + + } /> + + } /> + } /> + + + +); diff --git a/src/components/HomePage.tsx b/src/components/HomePage.tsx new file mode 100644 index 000000000..e6510554f --- /dev/null +++ b/src/components/HomePage.tsx @@ -0,0 +1,3 @@ +export const HomePage: React.FC = () => ( +

Home Page

+); diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index c2aa20f1c..c3b601138 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,4 +1,8 @@ -export const Navbar = () => { +import React from 'react'; +import { NavLink } from 'react-router-dom'; +import { getLinkClass } from '../helpers/getLinkClass'; + +export const Navbar: React.FC = () => { return ( diff --git a/src/components/NotFoundPage.tsx b/src/components/NotFoundPage.tsx new file mode 100644 index 000000000..4735b3144 --- /dev/null +++ b/src/components/NotFoundPage.tsx @@ -0,0 +1,3 @@ +export const NotFoundPage: React.FC = () => ( +

Page not found

+); diff --git a/src/components/PeopleFilters.tsx b/src/components/PeopleFilters.tsx index 2f1608bef..c04d30d06 100644 --- a/src/components/PeopleFilters.tsx +++ b/src/components/PeopleFilters.tsx @@ -1,14 +1,58 @@ -export const PeopleFilters = () => { +import classNames from 'classnames'; +import React from 'react'; +import { useSearchParams } from 'react-router-dom'; +import { SearchLink } from './SearchLink'; +import { CENTURIES, SEX_FILTER_LINKS } from '../utils/constants'; + +type Props = { + query: string, + sex: string, + centuries: string[], +}; + +export const PeopleFilters: React.FC = ({ + query, + sex, + centuries, +}) => { + const [searchParams, setSearchParams] = useSearchParams(); + + function handleChangeQuery(event: React.ChangeEvent) { + const params = new URLSearchParams(searchParams); + + params.set('query', event.target.value); + setSearchParams(params); + } + return (