generated from mate-academy/react_people-table
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1131
Open
ab3MN
wants to merge
13
commits into
mate-academy:master
Choose a base branch
from
ab3MN:develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Solution #1131
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fb632c0
feat:implemented filters
ab3MN 43a0de8
feat:implemented solution
ab3MN d20feca
refacor:fix eslint errors
ab3MN 441baff
refactor:refactor getPeopleView
ab3MN 3ffe87b
refactor:fix eslint errors
ab3MN 93ade90
refactor:refactor getPeopleWithParents,remove ParentLink
ab3MN 3fa2948
fix:fix all the comments
ab3MN f5b68bb
refactor:remove People context
ab3MN a11f415
refactor:refactor sorter types for Object to enum
ab3MN e237b3c
fix:fix all the eslint errors
ab3MN 7d24ec7
refactor:add paddingTop to Title,refacto Reset All filters Link
ab3MN 59ba8cc
refactor:refacot sort functions
ab3MN 108e653
refactor:refactor all the comments
ab3MN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { HashRouter, Navigate } from 'react-router-dom'; | ||
import { Routes, Route } from 'react-router-dom'; | ||
import { Suspense } from 'react'; | ||
import { App } from './App'; | ||
import { Routing } from './Routing/Routing'; | ||
import { Loader } from './components/Loader'; | ||
|
||
const { HomePage, PeoplePage, NotFoundPage } = Routing; | ||
|
||
export const Root = () => ( | ||
<HashRouter> | ||
<Suspense fallback={<Loader />}> | ||
<Routes> | ||
<Route path="/" element={<App />}> | ||
<Route index element={<HomePage />} /> | ||
<Route path="/home" element={<Navigate to="/" />} /> | ||
|
||
<Route path="people"> | ||
<Route path=":personId?" element={<PeoplePage />} /> | ||
</Route> | ||
|
||
<Route path="*" element={<NotFoundPage />} /> | ||
</Route> | ||
</Routes> | ||
</Suspense> | ||
</HashRouter> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { lazy } from 'react'; | ||
|
||
const PeoplePage = lazy(() => import('../pages/PeoplePage/PeoplePage')); | ||
const HomePage = lazy(() => import('../pages/HomePage/HomePage')); | ||
const NotFoundPage = lazy(() => import('../pages/NotFoundPage/NotFoundPage')); | ||
|
||
export const Routing = { | ||
PeoplePage, | ||
HomePage, | ||
NotFoundPage, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { NavLink } from 'react-router-dom'; | ||
import cn from 'classnames'; | ||
import { navLinks } from '../../constants/navLinks'; | ||
|
||
export const Nav = () => ( | ||
<nav | ||
data-cy="nav" | ||
className="navbar is-fixed-top has-shadow" | ||
role="navigation" | ||
aria-label="main navigation" | ||
> | ||
<div className="container"> | ||
<div className="navbar-brand"> | ||
{navLinks.map(({ path, title, id }) => ( | ||
<NavLink | ||
key={id} | ||
to={path} | ||
aria-current="page" | ||
className={({ isActive }) => | ||
cn('navbar-item', { 'has-background-grey-lighter': isActive }) | ||
} | ||
> | ||
{title} | ||
</NavLink> | ||
))} | ||
</div> | ||
</div> | ||
</nav> | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Loader } from '../Loader'; | ||
import { ErrorNotification } from '../../shared/ErrorNotification'; | ||
import { PeopleTable } from '../PeopleTable/PeopleTable'; | ||
import { usePeopleFilter } from '../../hooks/usePeopleFilter'; | ||
import { usePeople } from '../../hooks/usePeople'; | ||
|
||
export const People = () => { | ||
const { filtredPeople, isLoading, error, people } = usePeople(); | ||
const { centuries, name, sex } = usePeopleFilter(); | ||
|
||
const isPeopleEmpthy = !people.length && !isLoading; | ||
|
||
const isFilterParamsExist = !!(centuries.length || name || sex); | ||
|
||
const generatePeopleView = () => { | ||
switch (true) { | ||
case !!error: | ||
return ( | ||
<ErrorNotification dataCy="peopleLoadingError" errorMessage={error} /> | ||
); | ||
|
||
case isPeopleEmpthy: | ||
return ( | ||
<p data-cy="noPeopleMessage">There are no people on the server</p> | ||
); | ||
|
||
case !filtredPeople.length && isFilterParamsExist: | ||
return <p>There are no people matching the current search criteria</p>; | ||
|
||
case !!filtredPeople.length: | ||
return <PeopleTable people={filtredPeople} />; | ||
|
||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="column"> | ||
<div className="box table-container"> | ||
{isLoading && <Loader />} | ||
|
||
{generatePeopleView()} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import cn from 'classnames'; | ||
|
||
import { | ||
centuryLinksParams, | ||
sexLinksParams, | ||
} from '../../constants/personLinks'; | ||
import { SearchLink } from '../../shared/SearchLink'; | ||
import { usePeopleFilter } from '../../hooks/usePeopleFilter'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
export const PeopleFilters = () => { | ||
const { name, centuries, sex, handleChangeName, toogleCenturies } = | ||
usePeopleFilter(); | ||
|
||
return ( | ||
<div className="column is-7-tablet is-narrow-desktop"> | ||
<nav className="panel"> | ||
<p className="panel-heading">Filters</p> | ||
|
||
<p className="panel-tabs" data-cy="SexFilter"> | ||
{sexLinksParams.map(({ params, title }) => ( | ||
<SearchLink | ||
params={params} | ||
key={title} | ||
className={cn({ | ||
'is-active': sex === (params.sex ? params.sex : ''), | ||
})} | ||
> | ||
{title} | ||
</SearchLink> | ||
))} | ||
</p> | ||
|
||
<div className="panel-block"> | ||
<p className="control has-icons-left"> | ||
<input | ||
data-cy="NameFilter" | ||
type="search" | ||
className="input" | ||
placeholder="Search" | ||
onChange={e => handleChangeName(e.target.value)} | ||
value={name} | ||
/> | ||
|
||
<span className="icon is-left"> | ||
<i className="fas fa-search" aria-hidden="true" /> | ||
</span> | ||
</p> | ||
</div> | ||
|
||
<div className="panel-block"> | ||
<div | ||
className="level is-flex-grow-1 is-mobile" | ||
data-cy="CenturyFilter" | ||
> | ||
<div className="level-left"> | ||
{centuryLinksParams.map(({ century, title }) => ( | ||
<SearchLink | ||
key={title} | ||
data-cy="century" | ||
params={{ centuries: toogleCenturies(century) }} | ||
className={cn('button mr-1', { | ||
'is-info': centuries.includes(century), | ||
})} | ||
> | ||
{title} | ||
</SearchLink> | ||
))} | ||
</div> | ||
|
||
<div className="level-right ml-4"> | ||
<SearchLink | ||
data-cy="centuryALL" | ||
className={cn('button', 'is-success', { | ||
'is-outlined': centuries.length, | ||
})} | ||
params={{ centuries: null }} | ||
> | ||
All | ||
</SearchLink> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div className="panel-block"> | ||
<Link | ||
data-cy="centuryALL" | ||
className="button is-link is-outlined is-fullwidth" | ||
to="/people" | ||
> | ||
Reset all filters | ||
</Link> | ||
</div> | ||
</nav> | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isPeopleEmpthy => isPeopleEmpty