ajout contact presque ok

master
Maxence LANONE 3 years ago
parent 49275fbe90
commit c9c964d465

@ -0,0 +1,34 @@
{
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch via NPM",
"request": "launch",
"runtimeArgs": [
"run-script",
"debug"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"type": "chrome",
"request": "launch",
"name": "Lancer Chrome en utilisant localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}

@ -216,7 +216,7 @@ app.get('/Contact/AllWithCustomerName', (req, res) => {
});
app.get('/Entreprise/All', (req, res) => {
let sql = 'SELECT * FROM customers ORDER BY name';
let sql = 'SELECT idcustomer,name FROM customers ORDER BY name';
db.query(sql, (err, result) => {
if (err) throw err;
console.log(result);

@ -13,7 +13,7 @@ const api = axios.create({
baseURL: 'http://localhost:8080'
})
function AddContact(props) {
function AddContact() {
const [loginError, setLoginError] = useState(false);
const [entreprises, setEntreprises] = useState([]);
@ -29,37 +29,38 @@ function AddContact(props) {
function handleChangeEntreprise(event){
setSelectedIdEntreprise(event.target.value);
console.log("je suis dans handleChangeEntreprise");
};
function checkAdd(event){
// function checkAdd(event){
event.preventDefault();
// event.preventDefault();
const formData = new FormData(event.currentTarget);
const values = Object.fromEntries(formData.entries());
console.log(values.name);
api.get('/Contact/Exist/'+ values.login).then((response) => {
const login = response.data;
if (login.length > 0){
setLoginError(true);
}
else {
setLoginError(false);
// const formData = new FormData(event.currentTarget);
// const values = Object.fromEntries(formData.entries());
// console.log(values.name);
// api.get('/Contact/Exist/'+ values.login).then((response) => {
// const login = response.data;
// if (login.length > 0){
// setLoginError(true);
// }
// else {
// setLoginError(false);
api.post('/Contact/Add', values).then (function(response) {
console.log(response.data);
});
// api.post('/Contact/Add', values).then (function(response) {
// console.log(response.data);
// });
navigate("/Repertoire");
}
});
};
// navigate("/Repertoire");
// }
// });
// };
return (
<div className='addContactPage'>
<h2>Ajouter un nouveau contact</h2>
<div className="Formulaire">
<form className="form" onSubmit={checkAdd}>
<form className="form" >
<table className="Formulaire_de_connexion">
<tr>
<div className="texte_côté">
@ -92,4 +93,4 @@ function AddContact(props) {
)
}
export default AddContact
export default AddContact;

@ -28,6 +28,7 @@ function Admin_create() {
function handleChangeRole(event){
setSelectedIdRole(event.target.value);
console.log(event.target.value);
};
function checkAdd(event){

Loading…
Cancel
Save