Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksymKos committed Dec 8, 2023
1 parent 1386636 commit b004cd8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 79 deletions.
7 changes: 4 additions & 3 deletions src/components/PeopleFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { ChangeEvent } from 'react';
import cn from 'classnames';
import { SearchLink } from './SearchLink';
import { getSearchWith } from '../utils/searchHelper';
import { searchENUM } from '../types/serchENUM';

export const PeopleFilters = () => {
const [searchParams, setSearchParams] = useSearchParams();
const centuriesList = ['16', '17', '18', '19', '20'];

const sex = searchParams.get('sex');
const centuries = searchParams.getAll('centuries');
const query = searchParams.get('query') || '';
const sex = searchParams.get(searchENUM.Sex);
const centuries = searchParams.getAll(searchENUM.Centuries);
const query = searchParams.get(searchENUM.Query) || '';

function handleQuery(event: ChangeEvent<HTMLInputElement>) {
const params = (event.target.value === '')
Expand Down
17 changes: 12 additions & 5 deletions src/components/PeopleTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const PeopleTable: React.FC<Props> = ({ people, Slug }) => {

return (
<Link
to={`/people/${slug}`}
to={{
pathname: `/people/${slug}`,
search: searchParams.toString(),
}}
className={cn({ 'has-text-danger': sex === 'f' })}
>
{name}
Expand All @@ -59,7 +62,8 @@ export const PeopleTable: React.FC<Props> = ({ people, Slug }) => {
params={sortParams('name') as SearchParams}
>
<span className="icon">
<i className={cn('fas fa-sort', {
<i className={cn('fas', {
'fa-sort': sort !== 'name',
'fa-sort-up': sort === 'name' && !order,
'fa-sort-down': sort === 'name' && order,
})}
Expand All @@ -76,7 +80,8 @@ export const PeopleTable: React.FC<Props> = ({ people, Slug }) => {
params={sortParams('sex') as SearchParams}
>
<span className="icon">
<i className={cn('fas fa-sort', {
<i className={cn('fas', {
'fa-sort': sort !== 'sex',
'fa-sort-up': sort === 'sex' && !order,
'fa-sort-down': sort === 'sex' && order,
})}
Expand All @@ -93,7 +98,8 @@ export const PeopleTable: React.FC<Props> = ({ people, Slug }) => {
params={sortParams('born') as SearchParams}
>
<span className="icon">
<i className={cn('fas fa-sort', {
<i className={cn('fas', {
'fa-sort': sort !== 'born',
'fa-sort-up': sort === 'born' && !order,
'fa-sort-down': sort === 'born' && order,
})}
Expand All @@ -110,7 +116,8 @@ export const PeopleTable: React.FC<Props> = ({ people, Slug }) => {
params={sortParams('died') as SearchParams}
>
<span className="icon">
<i className={cn('fas fa-sort', {
<i className={cn('fas', {
'fa-sort': sort !== 'died',
'fa-sort-up': sort === 'died' && !order,
'fa-sort-down': sort === 'died' && order,
})}
Expand Down
50 changes: 0 additions & 50 deletions src/components/Person.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions src/components/PersonLink.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions src/types/serchENUM.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const searchENUM = {
Sex: 'sex',
Centuries: 'centuries',
Query: 'query',
};

0 comments on commit b004cd8

Please sign in to comment.