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 89679fd
Showing
16 changed files
with
523 additions
and
777 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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import { PeoplePage } from './components/PeoplePage'; | ||
import { Outlet } from 'react-router-dom'; | ||
import { Navbar } from './components/Navbar'; | ||
|
||
import './App.scss'; | ||
import { GlobalProvider } from './components/GeneralContext'; | ||
|
||
export const App = () => { | ||
return ( | ||
<div data-cy="app"> | ||
<Navbar /> | ||
<GlobalProvider> | ||
<div data-cy="app"> | ||
<Navbar /> | ||
|
||
<div className="section"> | ||
<div className="container"> | ||
<h1 className="title">Home Page</h1> | ||
<h1 className="title">Page not found</h1> | ||
<PeoplePage /> | ||
<div className="section"> | ||
<div className="container"> | ||
<Outlet /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</GlobalProvider> | ||
); | ||
}; |
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,45 @@ | ||
import React, { useState } from 'react'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { Context } from '../types/Context'; | ||
import { Person } from '../types'; | ||
|
||
const State: Context = { | ||
people: [], | ||
setPeople: () => {}, | ||
filteredPeople: [], | ||
setFilteredPeople: () => {}, | ||
sortedPeople: [], | ||
setSortedPeople: () => {}, | ||
searchParams: new URLSearchParams(), | ||
setSearchParams: () => {}, | ||
}; | ||
|
||
export const GlobalContext = React.createContext<Context>(State); | ||
|
||
type Props = { | ||
children: React.ReactNode | ||
}; | ||
|
||
export const GlobalProvider: React.FC<Props> = ({ children }) => { | ||
const [people, setPeople] = useState<Person[]>([]); | ||
const [filteredPeople, setFilteredPeople] = useState<Person[]>([]); | ||
const [sortedPeople, setSortedPeople] = useState<Person[]>([]); | ||
const [searchParams, setSearchParams] = useSearchParams(); | ||
|
||
const value = { | ||
people, | ||
setPeople, | ||
filteredPeople, | ||
setFilteredPeople, | ||
searchParams, | ||
setSearchParams, | ||
sortedPeople, | ||
setSortedPeople, | ||
}; | ||
|
||
return ( | ||
<GlobalContext.Provider value={value}> | ||
{children} | ||
</GlobalContext.Provider> | ||
); | ||
}; |
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,3 @@ | ||
export const HomePage: React.FC = () => ( | ||
<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,3 @@ | ||
export const PageNotFound: React.FC = () => ( | ||
<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
Oops, something went wrong.