Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyonaV22 committed Jan 2, 2025
1 parent 7628024 commit b7a8489
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<your_account>` with your Github username in the [DEMO LINK](https://<your_account>.github.io/react_people-table-advanced/) and add it to the PR description.
- Replace `<your_account>` with your Github username in the [DEMO LINK](https://AlyonaV22.github.io/react_people-table-advanced/) and add it to the PR description.
1 change: 1 addition & 0 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const CENTURIES = [16, 17, 18, 19, 20];
9 changes: 6 additions & 3 deletions src/pages/PeoplePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ const isSelectedPeople = (
if (query && query.trim()) {
const newQuery = query.toLowerCase();

const isQuery = (field: string | null | undefined): boolean =>
field?.toLowerCase().includes(newQuery) ?? false;

selectedPeople = selectedPeople.filter(
person =>
person.name.toLowerCase().includes(newQuery) ||
person.motherName?.toLowerCase().includes(newQuery) ||
person.fatherName?.toLowerCase().includes(newQuery),
isQuery(person.name) ||
isQuery(person.motherName) ||
isQuery(person.fatherName),
);
}

Expand Down
4 changes: 4 additions & 0 deletions src/types/sex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum Sex {
Male = 'm',
Female = 'f',
}

0 comments on commit b7a8489

Please sign in to comment.