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) => { 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) => { db.query(sql, (err, result) => {
if (err) throw err; if (err) throw err;
console.log(result); console.log(result);

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

Loading…
Cancel
Save