diff --git a/src/App.tsx b/src/App.tsx index adcb8594e..82367bb9d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,20 +1,23 @@ -import { PeoplePage } from './components/PeoplePage'; -import { Navbar } from './components/Navbar'; +import React from 'react'; +import { Routes, Route, Navigate } from 'react-router-dom'; +import { HomePage } from './HomePage/HomePage'; +import { PeoplePage } from './PeoplePage/PeoplePage'; +import { NotFoundPage } from './NotFoundPage/NotFoundPage'; +import { Navigation } from './Navigation/Navigation'; -import './App.scss'; - -export const App = () => { +export const App: React.FC = () => { return (
- - -
-
-

Home Page

-

Page not found

- -
-
+ +
+ + } /> + } /> + } /> + } /> + } /> + +
); }; diff --git a/src/HomePage/HomePage.tsx b/src/HomePage/HomePage.tsx new file mode 100644 index 000000000..b1b9f99a4 --- /dev/null +++ b/src/HomePage/HomePage.tsx @@ -0,0 +1,7 @@ +import React from 'react'; + +export const HomePage: React.FC = () => ( +
+

Home Page

+
+); diff --git a/src/Navigation/Navigation.tsx b/src/Navigation/Navigation.tsx new file mode 100644 index 000000000..2d89c18f5 --- /dev/null +++ b/src/Navigation/Navigation.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { Link, useLocation } from 'react-router-dom'; + +export const Navigation: React.FC = () => { + const location = useLocation(); + const isHome = location.pathname === '/'; + const isPeople = location.pathname.startsWith('/people'); + + return ( + + ); +}; diff --git a/src/NotFoundPage/NotFoundPage.tsx b/src/NotFoundPage/NotFoundPage.tsx new file mode 100644 index 000000000..9b70f5b8f --- /dev/null +++ b/src/NotFoundPage/NotFoundPage.tsx @@ -0,0 +1,9 @@ +import React from 'react'; + +export const NotFoundPage: React.FC = () => ( +
+
+

Page not found

+
+
+); diff --git a/src/PeopleFilter/PeopleFilter.tsx b/src/PeopleFilter/PeopleFilter.tsx new file mode 100644 index 000000000..ecf005328 --- /dev/null +++ b/src/PeopleFilter/PeopleFilter.tsx @@ -0,0 +1,108 @@ +import React from 'react'; +import { useSearchParams } from 'react-router-dom'; +import { SearchLink } from '../components/SearchLink'; +import classNames from 'classnames'; + +export const PeopleFilters = () => { + const [searchParams, setSearchParams] = useSearchParams(); + + const query = searchParams.get('query') || ''; + const gender = searchParams.get('sex') || ''; + const century = searchParams.getAll('century') || []; + + function handleQueryChange(event: React.ChangeEvent) { + const params = new URLSearchParams(searchParams); + + if (event.target.value) { + params.set('query', event.target.value); + } else { + params.delete('query'); + } + + setSearchParams(params); + } + + return ( +