2022-06-15 12:06:09 -04:00
|
|
|
import { useState, useEffect } from 'react'
|
|
|
|
import axios from 'axios'
|
2022-06-14 09:15:34 -04:00
|
|
|
|
|
|
|
import Filter from './components/Filter'
|
|
|
|
import Form from './components/Form'
|
|
|
|
import Numbers from './components/Numbers'
|
|
|
|
|
|
|
|
const App = () => {
|
|
|
|
const [filter, setFilter] = useState('')
|
2022-06-15 12:06:09 -04:00
|
|
|
const [persons, setPersons] = useState([])
|
|
|
|
|
|
|
|
useEffect(() => axios
|
|
|
|
.get('http://localhost:3001/persons')
|
|
|
|
.then(response => setPersons(response.data)), []);
|
2022-06-14 09:15:34 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h1>Phonebook</h1>
|
|
|
|
<Filter filter={filter} setFilter={setFilter} />
|
|
|
|
<Form persons={persons} setPersons={setPersons} />
|
|
|
|
<Numbers persons={persons} filter={filter.toLowerCase()} />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App
|