-
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
Initial solution #1110
base: master
Are you sure you want to change the base?
Initial solution #1110
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const HomePage = () => { | ||
return <h1 className="title">Home Page</h1>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './HomePage'; |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||||||||||||||
import cn from 'classnames'; | ||||||||||||||||||
import { NavLink } from 'react-router-dom'; | ||||||||||||||||||
|
||||||||||||||||||
export const Navbar = () => { | ||||||||||||||||||
return ( | ||||||||||||||||||
<nav | ||||||||||||||||||
data-cy="nav" | ||||||||||||||||||
className="navbar is-fixed-top has-shadow" | ||||||||||||||||||
role="navigation" | ||||||||||||||||||
aria-label="main navigation" | ||||||||||||||||||
> | ||||||||||||||||||
<div className="container"> | ||||||||||||||||||
<div className="navbar-brand"> | ||||||||||||||||||
<NavLink | ||||||||||||||||||
className={({ isActive }) => { | ||||||||||||||||||
return cn('navbar-item', { | ||||||||||||||||||
'has-background-grey-lighter': isActive, | ||||||||||||||||||
}); | ||||||||||||||||||
}} | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
to="/" | ||||||||||||||||||
> | ||||||||||||||||||
Home | ||||||||||||||||||
</NavLink> | ||||||||||||||||||
|
||||||||||||||||||
<NavLink | ||||||||||||||||||
aria-current="page" | ||||||||||||||||||
className={({ isActive }) => { | ||||||||||||||||||
return cn('navbar-item', { | ||||||||||||||||||
'has-background-grey-lighter': isActive, | ||||||||||||||||||
}); | ||||||||||||||||||
}} | ||||||||||||||||||
to="/people" | ||||||||||||||||||
> | ||||||||||||||||||
People | ||||||||||||||||||
</NavLink> | ||||||||||||||||||
</div> | ||||||||||||||||||
</div> | ||||||||||||||||||
</nav> | ||||||||||||||||||
); | ||||||||||||||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Navbar'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const PageNotFound = () => { | ||
return <h1 className="title">Page not found</h1>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './PageNotFound'; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import cn from 'classnames'; | ||
import { SearchLink } from '../SearchLink'; | ||
import { useFilters } from '../../hooks/useFilters'; | ||
import { CENTURIES } from '../../constants/CENTURIES'; | ||
|
||
export const PeopleFilters = () => { | ||
const { sex, query, centuries, handleSetQuery, getCenturiesParams } = | ||
useFilters(); | ||
|
||
return ( | ||
<nav className="panel"> | ||
<p className="panel-heading">Filters</p> | ||
|
||
<p className="panel-tabs" data-cy="SexFilter"> | ||
<SearchLink | ||
className={cn({ 'is-active': sex === null })} | ||
params={{ sex: null }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can create an |
||
> | ||
All | ||
</SearchLink> | ||
<SearchLink | ||
className={cn({ 'is-active': sex === 'm' })} | ||
params={{ sex: 'm' }} | ||
> | ||
Male | ||
</SearchLink> | ||
<SearchLink | ||
className={cn({ 'is-active': sex === 'f' })} | ||
params={{ sex: 'f' }} | ||
> | ||
Female | ||
</SearchLink> | ||
</p> | ||
|
||
<div className="panel-block"> | ||
<p className="control has-icons-left"> | ||
<input | ||
data-cy="NameFilter" | ||
type="search" | ||
className="input" | ||
placeholder="Search" | ||
value={query} | ||
onChange={event => { | ||
handleSetQuery(event.target.value); | ||
}} | ||
/> | ||
|
||
<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"> | ||
{CENTURIES.map(century => ( | ||
<SearchLink | ||
key={century} | ||
data-cy="century" | ||
params={{ | ||
centuries: getCenturiesParams(century), | ||
}} | ||
className={cn('button mr-1', { | ||
'is-info': centuries.includes(century), | ||
})} | ||
> | ||
{century} | ||
</SearchLink> | ||
))} | ||
</div> | ||
|
||
<div className="level-right ml-4"> | ||
<SearchLink | ||
data-cy="centuryALL" | ||
className={cn('button is-success', { | ||
'is-outlined': centuries.length !== 0, | ||
})} | ||
params={{ centuries: null }} | ||
> | ||
All | ||
</SearchLink> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div className="panel-block"> | ||
<SearchLink | ||
className={cn('button is-link is-outlined is-fullwidth', { | ||
'is-outlined': sex === null && !centuries.length && query === '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a variable for these conditions checks |
||
})} | ||
params={{ sex: null, centuries: null, query: null }} | ||
> | ||
Reset all filters | ||
</SearchLink> | ||
</div> | ||
</nav> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './PeopleFilters'; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Loader } from '../Loader'; | ||
import { PeopleFilters } from '../PeopleFilters'; | ||
import { PeopleTable } from '../PeopleTable'; | ||
|
||
import { usePeople } from '../../hooks/usePeople'; | ||
|
||
export const PeoplePage = () => { | ||
const { people, error, loading, filteredPeople } = usePeople(); | ||
|
||
const succesfullyLoadedStatus = !!people.length && !loading; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const isNoFilteredPeople = !filteredPeople.length && succesfullyLoadedStatus; | ||
|
||
return ( | ||
<> | ||
<h1 className="title">People Page</h1> | ||
|
||
<div className="block"> | ||
<div className="columns is-desktop is-flex-direction-row-reverse"> | ||
<div className="column is-7-tablet is-narrow-desktop"> | ||
{succesfullyLoadedStatus && <PeopleFilters />} | ||
</div> | ||
|
||
<div className="column"> | ||
<div className="box table-container"> | ||
{loading && <Loader />} | ||
|
||
{error && ( | ||
<p data-cy="peopleLoadingError">Something went wrong</p> | ||
)} | ||
|
||
{!people.length && !error && !loading && ( | ||
<p data-cy="noPeopleMessage"> | ||
There are no people on the server | ||
</p> | ||
)} | ||
|
||
{isNoFilteredPeople && ( | ||
<p>There are no people matching the current search criteria</p> | ||
)} | ||
|
||
{succesfullyLoadedStatus && ( | ||
<PeopleTable visiblePeople={filteredPeople} /> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
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.
Create an
enum
for paths