Skip to content

Commit

Permalink
added no match result for search and fixed click on people
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonHerasymov committed Oct 10, 2023
1 parent c04d7e3 commit d077c06
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function wait(delay: number) {
return new Promise(resolve => setTimeout(resolve, delay));
}

export function getPeople(): Promise<Person[]> {
export async function getPeople(): Promise<Person[]> {
// keep this delay for testing purpose
return wait(500)
.then(() => fetch(API_URL))
Expand Down
8 changes: 5 additions & 3 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import classNames from 'classnames';
import { NavLink } from 'react-router-dom';
import { NavLink, useSearchParams } from 'react-router-dom';

export const NavBar = () => {
export const Navbar = () => {
const getLinkClass = (
{ isActive }: { isActive: boolean },
) => classNames('navbar-item', {
'has-background-grey-lighter': isActive,
});

const [params] = useSearchParams();

return (
<nav
data-cy="nav"
Expand All @@ -26,7 +28,7 @@ export const NavBar = () => {

<NavLink
className={getLinkClass}
to="/people"
to={`./people?${params.toString()}`}
>
People
</NavLink>
Expand Down
4 changes: 2 additions & 2 deletions src/components/PageContent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Outlet } from 'react-router-dom';
import { NavBar } from './NavBar';
import { Navbar } from './Navbar';

export const PageContent = () => {
return (
<>
<NavBar />
<Navbar />

<main className="section">
<div className="container">
Expand Down
4 changes: 3 additions & 1 deletion src/components/PeopleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const PeopleList:React.FC<Props> = ({ people }) => {
order ? -1 : 1,
);

return (
return sortedPeople.length ? (
<table
data-cy="peopleTable"
className="
Expand Down Expand Up @@ -106,5 +106,7 @@ export const PeopleList:React.FC<Props> = ({ people }) => {
))}
</tbody>
</table>
) : (
<p>There are no people matching the current search criteria</p>
);
};

0 comments on commit d077c06

Please sign in to comment.