import NavigationDashboard from '../components/NavigationDashboard'; import React, { useState, useEffect } from 'react'; import { BrowserRouter as Router, Switch, Route, Routes } from 'react-router-dom'; import { v4 as uuid } from 'uuid'; import Header from '../components/Contact/Header'; import AddContact from '../components/Contact/AddContact' import ContactList from '../components/Contact/ContactList'; import ContactDetail from '../components/Contact/ContactDetail'; import EditContact from '../components/Contact/EditContact'; import axios from 'axios'; import user from '../images/user.jpg'; import { Link, useLocation } from 'react-router-dom'; import { TableContainer, Table, TableHead, TableBody, TableRow, TableCell } from '@mui/material'; import { Paper } from '@mui/material'; const api = axios.create({ baseURL: 'http://localhost:8080' }) function Repertoire() { const [contacts, setContacts] = useState([]); const [SearchTerm, setSearchTerm] = useState(""); const [SearchResults, setSearchResults] = useState([]); useEffect(() => { api.get('/Contact/All').then((response) => { setContacts(response.data); setSearchTerm(response.data[0].idcontact); }); }, []); return (
{/* Create a page to delete an user in the admin page*/}

Admin

Liste des utilisateurs

Nom Prénom Identifiant Téléphone {contacts.map((contact) => ( handleClick(event, contact.idcontact)} // selected={contact.idcontact === selectedIdcontact} > {contact.lastname} {contact.firstname} {contact.phone} {contact.mail} ))}
); } // function Repertoire() { // // NOW WITH THE USE OF HOOKS WE WILL GET THE CONTACTS // const LOCAL_STORAGE_KEY = "contacts" // const [contacts, setContacts] = useState([]); // const [SearchTerm, setSearchTerm] = useState(""); // const [SearchResults, setSearchResults] = useState([]); // const addContactHandler = async (contact) => { // const request = { // id: uuid(), // ...contact // } // const response = await api.post("/contacts", request) // setContacts([...contacts, response.data]); // } // // UPDATE CONTACT // const updateContactHandler = async (contact) => { // const response = await api.put(`/contacts/${contact.id}`, contact); // const { id, name, email } = response.data; // setContacts(contacts.map(contact => { // return contact.id === id ? { ...response.data } : contact; // })) // } // // FOR DELETING THE ITEMS // const removeContactHandler = async (id) => { // await api.delete(`/contacts/${id}`); // const newContactList = contacts.filter((contact) => { // return contact.id !== id; // }); // setContacts(newContactList); // } // // SEARCHING THE CONTACTS // const searchHandler = (searchTerm) => { // setSearchTerm(searchTerm); // if (searchTerm !== "") { // const newContactList = contacts.filter((contact) => { // return Object.values(contact).join(" ").toLowerCase().includes(searchTerm.toLowerCase()); // }); // setSearchResults(newContactList); // } else { // setSearchResults(contacts); // } // } // useEffect(() => { // const retrieveContacts = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY)); // if (retrieveContacts) setContacts(retrieveContacts); // } // , []); // useEffect(() => { // localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(contacts)); // } // , [contacts]); // return ( //
// //
// // } // render={(props)=>} // /> // } // //render={(props)=>} // /> // } // /> // } /> // // {/* */} // {/*Here in contact list props are used to get the values in the above contact array*/} // {/* */} // //
// ) // }; export default Repertoire;