Commit 260b1b00 authored by Anael Lacour's avatar Anael Lacour
Browse files

maj app.js with call

parent 9e8df20a
......@@ -9,20 +9,20 @@ import { loadByLogin, loadUserUVs, Mapper } from './api/edtutc';
function App() {
const [edt, setEDT] = useState([]);
const [uvs, setUvs] = useState([]);
const [edt, setUserEDT] = useState([]);
const [uvs, setUserUvs] = useState([]);
const [searchLogins, setSearchLogins] = useState(['lacouran']);
useEffect(() => {
console.log('In use effect');
searchLogins.forEach((login) => {
console.log('treating login : ' + login);
loadByLogin(login).then((data) => setEDT(edt.concat(Mapper(data)))).catch(err => console.log(err));
loadUserUVs(login).then((data) => setUvs(uvs.concat(data))).catch(err => console.log(err));
loadByLogin(login).then((data) => setUserEDT(edt.concat(Mapper(data)))).catch(err => console.log(err));
loadUserUVs(login).then((data) => setUserUvs(uvs.concat(data))).catch(err => console.log(err));
})
}, [searchLogins])
function handleSearch(input) {
function AddSearch(input) {
if (input === '') return;
setSearchLogins([...searchLogins, input]);
}
......@@ -31,17 +31,17 @@ function App() {
return arrOriginal.filter((el) => {return el !== elementToRemove})
}
function handleDelete(input){
function DeleteSerchedUser(input){
console.log('login to delete : ' + input);
let newArray = removeFromArray(searchLogins, input);
setSearchLogins(newArray);
setEDT([]);
setUvs([]);
setUserEDT([]);
setUserUvs([]);
}
return (
<div className="App">
<Header onSearch={handleSearch} onDelete={handleDelete} title='Emploi du temps' />
<Header onSearch={AddSearch} onDelete={DeleteSerchedUser} title='Emploi du temps' />
<p style={{ fontWeight: 'bold' }}>Vos UVs : {uvs.join(", ")}</p>
<p style={{ fontWeight: 'bold' }}>Vos Logins : {searchLogins.join(", ")}</p>
......@@ -51,8 +51,8 @@ function App() {
timeScale={{ interval: 60 }}
showWeekNumber={true}
startHour='7:00'
endHour='21:00'
height='600px'
endHour='20:00'
height='1000px'
width='900px'
>
<ViewsDirective>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment