reparation merge précédent

master
Tristan BARLET 2 years ago
parent abf2fbb75c
commit 68e98e4df3

@ -21,7 +21,6 @@ function Repertoire() {
const [contactSelectionne, setContactSelectionne] = useState(""); const [contactSelectionne, setContactSelectionne] = useState("");
const [modifContact, setModifContact] = useState(false); const [modifContact, setModifContact] = useState(false);
const [showConfirmation, setShowConfirmation] = useState(false); const [showConfirmation, setShowConfirmation] = useState(false);
console.log("showConfirmation", showConfirmation);
const [contacts, setContacts] = useState([]); const [contacts, setContacts] = useState([]);
const [SearchTerm, setSearchTerm] = useState(""); const [SearchTerm, setSearchTerm] = useState("");
const [SearchResults, setSearchResults] = useState([]); const [SearchResults, setSearchResults] = useState([]);
@ -43,14 +42,6 @@ function Repertoire() {
}); });
}, []); }, []);
function onClickDetail() {
return <NavLink to="/Repertoire/add">
</NavLink>
}
function handleDeleteClick(contact) { function handleDeleteClick(contact) {
api.delete('/Contact/Delete/' + contact.idcontact).then((response) => { api.delete('/Contact/Delete/' + contact.idcontact).then((response) => {
const newContacts = contacts.filter((c) => c.idcontact !== contact.idcontact); const newContacts = contacts.filter((c) => c.idcontact !== contact.idcontact);
@ -169,36 +160,65 @@ function Repertoire() {
<TableCell>Nom</TableCell> <TableCell>Nom</TableCell>
<TableCell>Prénom</TableCell> <TableCell>Prénom</TableCell>
<TableCell>Entreprise</TableCell> <TableCell>Entreprise</TableCell>
<TableContainer component={Paper} className="tabListContact" style={{color: '#fff'}}> </TableRow>
<Table> </TableHead>
<TableHead> <TableBody>
<TableRow className="headerListe">
<TableCell>Photo</TableCell>
<TableCell>Nom</TableCell>
<TableCell>Prénom</TableCell>
<TableCell>Entreprise</TableCell>
<TableCell>Supprimer</TableCell>
</TableRow>
</TableHead>
<TableBody>
{contacts.map((contact) => ( {contacts.map((contact) => (
<TableRow key={contact.idcontact} onClick={onClickDetail()}> <TableRow key={contact.idcontact} onClick={() => setContactSelectionne(contact)}>
<TableCell><img className="photoContact" src={user} /></TableCell>
<TableCell><img className="photoContact" src={user} /></TableCell> <TableCell>{contact.lastname}</TableCell>
<TableCell>{contact.lastname}</TableCell> <TableCell>{contact.firstname}</TableCell>
<TableCell>{contact.firstname}</TableCell> <TableCell>{contact.name}</TableCell>
<TableCell>{contact.name}</TableCell> </TableRow>
))}
</TableBody>
</Table>
</TableContainer>
: !modifContact ?
<div>
<h2>{contactSelectionne.lastname} {contactSelectionne.firstname}</h2>
<p>Mail: {contactSelectionne.mail}</p>
<p>Numéro de téléphone: {contactSelectionne.phone}</p>
<p>Entreprise: {contactSelectionne.name}</p>
{!showConfirmation ?
<div>
<button className="boutonSupprimer" onClick={() => setShowConfirmation(true)}>Supprimer</button>
<button className="boutonModifier" onClick={() => setModifContact(true)}>Modifier</button>
</div>
:
<div>
<p>Êtes-vous sûr de vouloir supprimer ce contact ?</p>
<button className="boutonSupprimer" onClick={() => handleDeleteClick(contactSelectionne)}>Supprimer</button>
</div>
}
</div>
:
<ContactForm contact={contactSelectionne} setModifContact={setModifContact} />
}
</div>
</div>
</div>
</body>
);
};
function SupprimerContact(props) {
<TableCell><button className="boutonSuppContact" onClick={() => handleDeleteClick(contact)}>Supprimer</button></TableCell> const navigate = useNavigate();
</TableRow> const deleteContact = (id) => {
))} api.delete('/Contact/' + id).then(() => {
props.getContactList();
});
};
</TableBody> return (
</Table> <div className="ui main">
</TableContainer> <h2>Supprimer Contact</h2>
</div> <button className="ui button blue" onClick={() => deleteContact(props.id)}>Supprimer</button>
</div>
);
}

Loading…
Cancel
Save