generated from mate-academy/react_people-table
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7bec0e
commit 1ffa8b4
Showing
16 changed files
with
379 additions
and
742 deletions.
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,35 @@ | ||
import { useParams } from 'react-router-dom'; | ||
import classNames from 'classnames'; | ||
import { PersonLink } from './components/PersonLink'; | ||
import { Person } from './types'; | ||
|
||
type Props = { | ||
person: Person; | ||
}; | ||
|
||
export const PeopleRow: React.FC<Props> = ({ person }) => { | ||
const { | ||
sex, born, died, fatherName, motherName, father, mother, | ||
} = person; | ||
const { slug } = useParams(); | ||
|
||
return ( | ||
<tr | ||
data-cy="person" | ||
className={classNames({ | ||
'has-background-warning': person.slug === slug, | ||
})} | ||
> | ||
|
||
<td aria-label="person"> | ||
<PersonLink person={person} /> | ||
</td> | ||
|
||
<td>{sex}</td> | ||
<td>{born}</td> | ||
<td>{died}</td> | ||
<td>{mother ? (<PersonLink person={mother} />) : (motherName || '-')}</td> | ||
<td>{father ? (<PersonLink person={father} />) : (fatherName || '-')}</td> | ||
</tr> | ||
); | ||
}; |
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 { | ||
Navigate, | ||
Route, | ||
HashRouter as Router, | ||
Routes, | ||
} from 'react-router-dom'; | ||
import { HomePage } from './components/HomePage'; | ||
import { PeoplePage } from './components/PeoplePage'; | ||
import { NotFoundPage } from './components/NotFoundPage'; | ||
import { App } from './App'; | ||
|
||
export const Root = () => { | ||
return ( | ||
<Router> | ||
<Routes> | ||
<Route> | ||
<Route path="/" element={<App />}> | ||
<Route index element={<HomePage />} /> | ||
<Route path="home" element={<Navigate to="/" replace />} /> | ||
<Route path="people"> | ||
<Route path=":slug?" element={<PeoplePage />} /> | ||
</Route> | ||
<Route path="*" element={<NotFoundPage />} /> | ||
</Route> | ||
</Route> | ||
</Routes> | ||
</Router> | ||
); | ||
}; |
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,5 @@ | ||
export const HomePage = () => { | ||
return ( | ||
<h1 className="title">Home Page</h1> | ||
); | ||
}; |
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,5 @@ | ||
export const NotFoundPage: React.FC = () => { | ||
return ( | ||
<h1 className="title">Page not found</h1> | ||
); | ||
}; |
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
Oops, something went wrong.