From aac1b22e91c42f2af643e10d18d07cb5d8fc8c3c Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Sun, 27 Nov 2022 09:57:32 +0100 Subject: [PATCH 1/9] ajout fonction ajouter repertoire (pas fini) --- .scannerwork/.sonar_lock | 0 .scannerwork/report-task.txt | 6 ++++++ src/pages/Repertoire.js | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .scannerwork/.sonar_lock create mode 100644 .scannerwork/report-task.txt diff --git a/.scannerwork/.sonar_lock b/.scannerwork/.sonar_lock new file mode 100644 index 0000000..e69de29 diff --git a/.scannerwork/report-task.txt b/.scannerwork/report-task.txt new file mode 100644 index 0000000..1953886 --- /dev/null +++ b/.scannerwork/report-task.txt @@ -0,0 +1,6 @@ +projectKey=jtt_crm +serverUrl=https://codefirst.iut.uca.fr/sonar +serverVersion=9.6.1.59531 +dashboardUrl=https://codefirst.iut.uca.fr/sonar/dashboard?id=jtt_crm +ceTaskId=AYSvDEjizKKB0GF_0uUi +ceTaskUrl=https://codefirst.iut.uca.fr/sonar/api/ce/task?id=AYSvDEjizKKB0GF_0uUi diff --git a/src/pages/Repertoire.js b/src/pages/Repertoire.js index c32adf3..2c75f50 100644 --- a/src/pages/Repertoire.js +++ b/src/pages/Repertoire.js @@ -62,7 +62,7 @@ function Repertoire() { - + @@ -119,6 +119,10 @@ function Repertoire() { ); }; +function ajouter() { + console.log("ajouter"); +}; + // function Repertoire() { // // NOW WITH THE USE OF HOOKS WE WILL GET THE CONTACTS From 49275fbe90c852a1b35156d7a87218916462456b Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Sun, 27 Nov 2022 15:10:20 +0100 Subject: [PATCH 2/9] =?UTF-8?q?mise=20en=20forme=20du=20fomulaire=20avec?= =?UTF-8?q?=20donn=C3=A9es=20bdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-api/api.js | 38 +++++- src/App.js | 2 + src/components/Contact/AddContact.js | 109 +++++++++++++----- src/pages/Repertoire.js | 49 +++++++- src/styles/components/_repertoire.scss | 1 + .../components/contact/_addContact.scss | 8 ++ src/styles/index.scss | 3 +- 7 files changed, 174 insertions(+), 36 deletions(-) create mode 100644 src/styles/components/contact/_addContact.scss diff --git a/server-api/api.js b/server-api/api.js index c95ec21..8117453 100644 --- a/server-api/api.js +++ b/server-api/api.js @@ -213,4 +213,40 @@ app.get('/Contact/AllWithCustomerName', (req, res) => { console.log(result); res.send(result); }); -}); \ No newline at end of file +}); + +app.get('/Entreprise/All', (req, res) => { + let sql = 'SELECT * FROM customers ORDER BY name'; + db.query(sql, (err, result) => { + if (err) throw err; + console.log(result); + res.send(result); + }); +}); + +app.get('/Contact/Exist/:login', (req, res) => { + + const login = req.params.login; + let sql = 'SELECT idContact FROM contact WHERE login = ?'; + + db.query(sql, [login], (err, result) => { + if (err) throw err; + + console.log(result); + res.send(result); + }); +}); + +app.post('/Contact/Add', (req, res) => { + + let form = req.body; + + console.log(form); + + const sql = `INSERT INTO contact(name, firstname, mail, phone, idUser, idCustomer) VALUES ('${form.name}', '${form.firstname}', '${form.mail}', '${form.phone}' , '${form.idrole}', '${form.idUser}', '${form.idCustomer}' )`; + db.query(sql , (err, result) => { + if (err) throw err; + console.log(result); + res.send('Post added...' + result.insertId); + }); +}); diff --git a/src/App.js b/src/App.js index f2910b2..552dbb7 100644 --- a/src/App.js +++ b/src/App.js @@ -13,6 +13,7 @@ import Calendrier from './pages/Calendrier'; import Repertoire from './pages/Repertoire'; import Parametres from './pages/Parametres'; import Chargement from './pages/Chargement'; +import AddContact from './components/Contact/AddContact' import { Component } from 'fullcalendar'; import RestartPassword from './pages/RestartPassword'; @@ -38,6 +39,7 @@ const App = () => { } /> } /> } /> + } /> ); diff --git a/src/components/Contact/AddContact.js b/src/components/Contact/AddContact.js index c9c0c60..26a6e71 100644 --- a/src/components/Contact/AddContact.js +++ b/src/components/Contact/AddContact.js @@ -1,40 +1,93 @@ -import React, {useState} from 'react' -import {useNavigate} from 'react-router-dom'; +import React, { useState, useEffect } from 'react'; +import axios from 'axios' +import NavigationDashboard from '../NavigationDashboard.js'; +import CryptoJS from 'crypto-js'; +import Select, { SelectChangeEvent } from '@mui/material/Select'; +import MenuItem from '@mui/material/MenuItem'; +import { NavLink } from 'react-router-dom'; +import { useNavigate } from "react-router-dom"; +import { Button } from '@mui/material'; // HERE ABOVE useHistory IS REPLACED WITH useNavigate +const api = axios.create({ + baseURL: 'http://localhost:8080' + }) + function AddContact(props) { + + const [loginError, setLoginError] = useState(false); + const [entreprises, setEntreprises] = useState([]); + const [selectedIdEntreprise, setSelectedIdEntreprise] = useState(1); const navigate=useNavigate(); - const [User, setUser] = useState({name:"", email:""}); - let add = (e) => { - e.preventDefault(); - if(User.name === "" || User.email === ""){ - alert("All fields are mandatory!!!"); - return - } - // THIS IS USED TO SHOW THE LIST DATA ON THE APP.JS FILE - props.addContactHandler(User); - // THIS IS USED FOR WHEN THE ADD BUTTON IS PRESSED THE INPUT FILED AGAIN GETS EMPTY - setUser({name:"", email:""}); - //console.log(props); - navigate('/'); - } + useEffect(() =>{ + api.get('/Entreprise/All').then((response) => { + setEntreprises(response.data); + }); + }, []); + + function handleChangeEntreprise(event){ + setSelectedIdEntreprise(event.target.value); + }; + + function checkAdd(event){ + + 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); + + api.post('/Contact/Add', values).then (function(response) { + console.log(response.data); + }); + + navigate("/Repertoire"); + } + }); + }; return ( -
-

Add Contact

-
-
- - setUser({...User, name: e.target.value})}/> -
-
- - setUser({...User, email: e.target.value})}/> +
+

Ajouter un nouveau contact

+
+ +
+ +
+

Nom :

+

Prénom :

+

Téléphone :

+

Email :

+

Entreprise :

+
+ + + + + + + + +
+

{loginError === true?"L'identifiant existe déja":''}

+
+ + Retour +
+ - - ) } diff --git a/src/pages/Repertoire.js b/src/pages/Repertoire.js index 2c75f50..e52d96d 100644 --- a/src/pages/Repertoire.js +++ b/src/pages/Repertoire.js @@ -4,7 +4,8 @@ import axios from 'axios'; import user from '../images/user.jpg'; import { TableContainer, Table, TableHead, TableBody, TableRow, TableCell } from '@mui/material'; import { Paper } from '@mui/material'; - +import { NavLink } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; const api = axios.create({ baseURL: 'http://localhost:8080' @@ -12,7 +13,7 @@ const api = axios.create({ function Repertoire() { - const [theme, setTheme] = useState("light"); + const [theme, setTheme] = useState("light"); if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) { setTheme(localStorage.getItem("theme")) } @@ -21,7 +22,7 @@ function Repertoire() { const [SearchTerm, setSearchTerm] = useState(""); const [SearchResults, setSearchResults] = useState([]); const [customers, setCustomers] = useState([]); - + useEffect(() => { api.get('/Contact/AllWithCustomerName').then((response) => { @@ -62,7 +63,9 @@ function Repertoire() { - + + + @@ -119,10 +122,44 @@ function Repertoire() { ); }; -function ajouter() { - console.log("ajouter"); +function AddContact(props) { + + const navigate = useNavigate(); + const [User, setUser] = useState({ name: "", email: "" }); + + let add = (e) => { + e.preventDefault(); + if (User.name === "" || User.email === "") { + alert("All fields are mandatory!!!"); + return + } + // THIS IS USED TO SHOW THE LIST DATA ON THE APP.JS FILE + props.addContactHandler(User); + // THIS IS USED FOR WHEN THE ADD BUTTON IS PRESSED THE INPUT FILED AGAIN GETS EMPTY + setUser({ name: "", email: "" }); + //console.log(props); + navigate('/'); + } + return ( +
+

Add Contact

+
+
+ + setUser({ ...User, name: e.target.value })} /> +
+
+ + setUser({ ...User, email: e.target.value })} /> +
+ + +
+ ); }; + + // function Repertoire() { // // NOW WITH THE USE OF HOOKS WE WILL GET THE CONTACTS diff --git a/src/styles/components/_repertoire.scss b/src/styles/components/_repertoire.scss index 7ed5f78..452f105 100644 --- a/src/styles/components/_repertoire.scss +++ b/src/styles/components/_repertoire.scss @@ -177,6 +177,7 @@ body { margin: 30px 30px; border-radius: 25px; box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); + text-decoration-line: none; } .input_box { diff --git a/src/styles/components/contact/_addContact.scss b/src/styles/components/contact/_addContact.scss new file mode 100644 index 0000000..b79b38c --- /dev/null +++ b/src/styles/components/contact/_addContact.scss @@ -0,0 +1,8 @@ +.addContactPage{ + display: flex; + flex-direction: column; + justify-content: space-around; + align-items: center; + + +} \ No newline at end of file diff --git a/src/styles/index.scss b/src/styles/index.scss index ac6a812..eb40ba3 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -7,4 +7,5 @@ @import "./components/calendrier"; @import "./components/parametre"; @import "./components/repertoire"; -@import "./components/chargement" \ No newline at end of file +@import "./components/chargement"; +@import "./components/contact/addContact"; \ No newline at end of file From c9c964d4657bbfb1f1dca52afa0bfa577a0d3c46 Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 9 Dec 2022 10:36:55 +0100 Subject: [PATCH 3/9] ajout contact presque ok --- .vscode/launch.json | 34 +++++++++++++++++++++ server-api/api.js | 2 +- src/components/Contact/AddContact.js | 45 ++++++++++++++-------------- src/pages/Admin_create.js | 1 + 4 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4b52bef --- /dev/null +++ b/.vscode/launch.json @@ -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": [ + "/**" + ], + "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}" + } + ] +} \ No newline at end of file diff --git a/server-api/api.js b/server-api/api.js index 8117453..0e318fa 100644 --- a/server-api/api.js +++ b/server-api/api.js @@ -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); diff --git a/src/components/Contact/AddContact.js b/src/components/Contact/AddContact.js index 26a6e71..b8eb6ae 100644 --- a/src/components/Contact/AddContact.js +++ b/src/components/Contact/AddContact.js @@ -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 (

Ajouter un nouveau contact

-
+
@@ -92,4 +93,4 @@ function AddContact(props) { ) } -export default AddContact +export default AddContact; diff --git a/src/pages/Admin_create.js b/src/pages/Admin_create.js index b9d2528..4d23907 100644 --- a/src/pages/Admin_create.js +++ b/src/pages/Admin_create.js @@ -28,6 +28,7 @@ function Admin_create() { function handleChangeRole(event){ setSelectedIdRole(event.target.value); + console.log(event.target.value); }; function checkAdd(event){ From e10cc6291f3aa7543d21b28a6c1b725ad84925ff Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 9 Dec 2022 10:37:54 +0100 Subject: [PATCH 4/9] ajout contact presque ok (ajout mais crash de la base apres car manque authentification) --- package-lock.json | 33 +++++++++++++++----- package.json | 3 +- server-api/1 | 1 + server-api/api.js | 9 +++--- server-api/kill | 1 + src/components/Contact/AddContact.js | 45 ++++++++++++++-------------- 6 files changed, 57 insertions(+), 35 deletions(-) create mode 100644 server-api/1 create mode 100644 server-api/kill diff --git a/package-lock.json b/package-lock.json index 6583b16..61260d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "addeventlistener": "^2.0.0", "axios": "^1.2.0", "chart": "^0.1.2", - "chart.js": "^3.9.1", + "chart.js": "^4.0.1", "crypto-js": "^4.1.1", "darkreader": "^4.9.58", "date-fns": "^2.29.3", @@ -30,6 +30,7 @@ "pg": "^8.8.0", "react": "^18.2.0", "react-big-calendar": "^1.5.0", + "react-chartjs-2": "^5.0.1", "react-datepicker": "^4.8.0", "react-dom": "^18.2.0", "react-loading": "^2.0.3", @@ -6127,9 +6128,12 @@ } }, "node_modules/chart.js": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.9.1.tgz", - "integrity": "sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w==" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.0.1.tgz", + "integrity": "sha512-5/8/9eBivwBZK81mKvmIwTb2Pmw4D/5h1RK9fBWZLLZ8mCJ+kfYNmV9rMrGoa5Hgy2/wVDBMLSUDudul2/9ihA==", + "engines": { + "pnpm": "^7.0.0" + } }, "node_modules/check-types": { "version": "11.1.2", @@ -14776,6 +14780,15 @@ "react-dom": "^16.14.0 || ^17 || ^18" } }, + "node_modules/react-chartjs-2": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.0.1.tgz", + "integrity": "sha512-u38C9OxynlNCBp+79grgXRs7DSJ9w8FuQ5/HO5FbYBbri8HSZW+9SWgjVshLkbXBfXnMGWakbHEtvN0nL2UG7Q==", + "peerDependencies": { + "chart.js": "^4.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-datepicker": { "version": "4.8.0", "resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-4.8.0.tgz", @@ -22197,9 +22210,9 @@ } }, "chart.js": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.9.1.tgz", - "integrity": "sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w==" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.0.1.tgz", + "integrity": "sha512-5/8/9eBivwBZK81mKvmIwTb2Pmw4D/5h1RK9fBWZLLZ8mCJ+kfYNmV9rMrGoa5Hgy2/wVDBMLSUDudul2/9ihA==" }, "check-types": { "version": "11.1.2", @@ -28276,6 +28289,12 @@ "uncontrollable": "^7.2.1" } }, + "react-chartjs-2": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.0.1.tgz", + "integrity": "sha512-u38C9OxynlNCBp+79grgXRs7DSJ9w8FuQ5/HO5FbYBbri8HSZW+9SWgjVshLkbXBfXnMGWakbHEtvN0nL2UG7Q==", + "requires": {} + }, "react-datepicker": { "version": "4.8.0", "resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-4.8.0.tgz", diff --git a/package.json b/package.json index 10f2b72..11d87d7 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "addeventlistener": "^2.0.0", "axios": "^1.2.0", "chart": "^0.1.2", - "chart.js": "^3.9.1", + "chart.js": "^4.0.1", "crypto-js": "^4.1.1", "darkreader": "^4.9.58", "date-fns": "^2.29.3", @@ -25,6 +25,7 @@ "pg": "^8.8.0", "react": "^18.2.0", "react-big-calendar": "^1.5.0", + "react-chartjs-2": "^5.0.1", "react-datepicker": "^4.8.0", "react-dom": "^18.2.0", "react-loading": "^2.0.3", diff --git a/server-api/1 b/server-api/1 new file mode 100644 index 0000000..0a1c474 --- /dev/null +++ b/server-api/1 @@ -0,0 +1 @@ +703 diff --git a/server-api/api.js b/server-api/api.js index 0e318fa..751c6d4 100644 --- a/server-api/api.js +++ b/server-api/api.js @@ -224,12 +224,11 @@ app.get('/Entreprise/All', (req, res) => { }); }); -app.get('/Contact/Exist/:login', (req, res) => { - - const login = req.params.login; - let sql = 'SELECT idContact FROM contact WHERE login = ?'; +app.get('/Contact/Exist/:phone', (req, res) => { + const phone = req.params.phone + let sql = 'SELECT idcontact FROM contacts WHERE phone = ?'; - db.query(sql, [login], (err, result) => { + db.query(sql, [phone], (err, result) => { if (err) throw err; console.log(result); diff --git a/server-api/kill b/server-api/kill new file mode 100644 index 0000000..0a1c474 --- /dev/null +++ b/server-api/kill @@ -0,0 +1 @@ +703 diff --git a/src/components/Contact/AddContact.js b/src/components/Contact/AddContact.js index b8eb6ae..1a2d794 100644 --- a/src/components/Contact/AddContact.js +++ b/src/components/Contact/AddContact.js @@ -24,6 +24,7 @@ function AddContact() { useEffect(() =>{ api.get('/Entreprise/All').then((response) => { setEntreprises(response.data); + console.log(entreprises); }); }, []); @@ -32,35 +33,35 @@ function AddContact() { 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.idcontact).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); - // }); - - // navigate("/Repertoire"); - // } - // }); - // }; + api.post('/Contact/Add', values).then (function(response) { + console.log(response.data); + }); + + navigate("/Repertoire"); + } + }); + }; return (

Ajouter un nouveau contact

- +
@@ -78,7 +79,7 @@ function AddContact() { placeholder="Téléphone..." pattern="[0-9]{10}" required/>
From a024b2da3800a8edc85636c9fcc60f8f47a6abea Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 9 Dec 2022 11:02:09 +0100 Subject: [PATCH 5/9] ajout opt mac --- .vscode/c_cpp_properties.json | 18 ++++++++++ .vscode/launch.json | 65 +++++++++++++++++++---------------- .vscode/settings.json | 36 +++++++++++++++++++ 3 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/settings.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..980fd57 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "macos-clang-arm64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "macos-clang-arm64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 4b52bef..1f47c3b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,34 +1,39 @@ { - // 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": [ + "version": "0.2.0", + "configurations": [ { - "name": "Launch via NPM", - "request": "launch", - "runtimeArgs": [ - "run-script", - "debug" - ], - "runtimeExecutable": "npm", - "skipFiles": [ - "/**" - ], - "type": "node" + "name": "Launch via NPM", + "request": "launch", + "runtimeArgs": [ + "run-script", + "debug" + ], + "runtimeExecutable": "npm", + "skipFiles": [ + "/**" + ], + "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}" - } - ] + { + "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}" + }, + { + "name": "C/C++ Runner: Debug Session", + "type": "lldb", + "request": "launch", + "args": [], + "cwd": "/Users/malanone/JTT_Production/JTT_CrM", + "program": "/Users/malanone/JTT_Production/JTT_CrM/build/Debug/outDebug" + } + ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..50d1b0f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,36 @@ +{ + "C_Cpp_Runner.cCompilerPath": "clang", + "C_Cpp_Runner.cppCompilerPath": "clang++", + "C_Cpp_Runner.debuggerPath": "lldb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wconversion", + "-Wnull-dereference", + "-Wsign-conversion" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ] +} \ No newline at end of file From 9f7a57a2dba99b8c39967c7f3392ce3786adf98e Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 9 Dec 2022 14:07:47 +0100 Subject: [PATCH 6/9] fichier vscode --- .vscode/c_cpp_properties.json | 18 ++++++++++++++++++ .vscode/launch.json | 13 +++++++++++++ .vscode/settings.json | 36 +++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..980fd57 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "macos-clang-arm64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "macos-clang-arm64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..6053dbd --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "lldb", + "request": "launch", + "args": [], + "cwd": "/Users/malanone/JTT_Production/JTT_CrM", + "program": "/Users/malanone/JTT_Production/JTT_CrM/build/Debug/outDebug" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..50d1b0f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,36 @@ +{ + "C_Cpp_Runner.cCompilerPath": "clang", + "C_Cpp_Runner.cppCompilerPath": "clang++", + "C_Cpp_Runner.debuggerPath": "lldb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wconversion", + "-Wnull-dereference", + "-Wsign-conversion" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ] +} \ No newline at end of file From 08e192d5bacfd2c77abcc9aa381ee66c08523301 Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 9 Dec 2022 20:55:28 +0100 Subject: [PATCH 7/9] reglage add contact --- server-api/1 | 1 - server-api/api.js | 6 +++--- server-api/kill | 1 - src/components/Contact/AddContact.js | 19 ++++++++++++------- src/components/Menu.js | 11 ----------- src/pages/Calendrier.js | 1 + src/pages/Repertoire.js | 7 +++++-- src/styles/components/_repertoire.scss | 23 +++++++++-------------- 8 files changed, 30 insertions(+), 39 deletions(-) delete mode 100644 server-api/1 delete mode 100644 server-api/kill delete mode 100644 src/components/Menu.js diff --git a/server-api/1 b/server-api/1 deleted file mode 100644 index 0a1c474..0000000 --- a/server-api/1 +++ /dev/null @@ -1 +0,0 @@ -703 diff --git a/server-api/api.js b/server-api/api.js index 8217b8a..d565404 100644 --- a/server-api/api.js +++ b/server-api/api.js @@ -312,9 +312,9 @@ app.post('/Contact/Add', (req, res) => { let form = req.body; - console.log(form); + console.log("on est dans le form",form); - const sql = `INSERT INTO contact(name, firstname, mail, phone, idUser, idCustomer) VALUES ('${form.name}', '${form.firstname}', '${form.mail}', '${form.phone}' , '${form.idrole}', '${form.idUser}', '${form.idCustomer}' )`; + const sql = `INSERT INTO contacts(firstname,lastname, mail, phone, iduser, idcustomer) VALUES ('${form.firstname}', '${form.lastname}', '${form.mail}', '${form.phone}', '${form.iduser}', '${form.idcustomer}' )`; db.query(sql , (err, result) => { if (err) throw err; console.log(result); @@ -338,7 +338,7 @@ app.post('/Event/Add', (req, res) => { let form = req.body; - console.log(form); + console.log("on est dans le form d'un event ",form); const sql = `INSERT INTO events(date,starttime,endtime,comment,idusersend,iduserreceive,idcontact) VALUES ('${form.date}', '${form.starttime}', '${form.endtime}', '${form.comment}', '${form.idusersend}', '${form.iduserreceive}', '${form.idcontact}')`; db.query(sql , (err, result) => { diff --git a/server-api/kill b/server-api/kill deleted file mode 100644 index 0a1c474..0000000 --- a/server-api/kill +++ /dev/null @@ -1 +0,0 @@ -703 diff --git a/src/components/Contact/AddContact.js b/src/components/Contact/AddContact.js index 1a2d794..8bf59aa 100644 --- a/src/components/Contact/AddContact.js +++ b/src/components/Contact/AddContact.js @@ -7,6 +7,7 @@ import MenuItem from '@mui/material/MenuItem'; import { NavLink } from 'react-router-dom'; import { useNavigate } from "react-router-dom"; import { Button } from '@mui/material'; +import Session from 'react-session-api'; // HERE ABOVE useHistory IS REPLACED WITH useNavigate const api = axios.create({ @@ -18,6 +19,7 @@ function AddContact() { const [loginError, setLoginError] = useState(false); const [entreprises, setEntreprises] = useState([]); const [selectedIdEntreprise, setSelectedIdEntreprise] = useState(1); + const [newContact, setNewContact] = useState([]); const navigate=useNavigate(); @@ -39,21 +41,24 @@ function AddContact() { const formData = new FormData(event.currentTarget); const values = Object.fromEntries(formData.entries()); - console.log(values.name); - api.get('/Contact/Exist/'+ values.idcontact).then((response) => { + setNewContact(values); + setNewContact(newContact => [...newContact, Session.get('idUser')]); + console.log("c'est le new contact " ,newContact); + api.get('/Contact/Exist/'+ values.phone).then((response) => { const login = response.data; if (login.length > 0){ setLoginError(true); } else { setLoginError(false); - - api.post('/Contact/Add', values).then (function(response) { + const newContact = [firstname:values.firstname, lastname:values.lastname, phone:values.phone, mail:values.email, iduser:Session.get('idUser'), idcustomer:values.selectedIdEntreprise]; + api.post('/Contact/Add', newContact).then (function(response) { console.log(response.data); }); + console.log("c'est le new contact " ,newContact); - navigate("/Repertoire"); } + navigate("/Repertoire"); }); }; @@ -73,8 +78,8 @@ function AddContact() { - - + + diff --git a/src/components/Menu.js b/src/components/Menu.js deleted file mode 100644 index 7c04e13..0000000 --- a/src/components/Menu.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; - -const Menu = () => { - return ( -
- -
- ); -}; - -export default Menu; \ No newline at end of file diff --git a/src/pages/Calendrier.js b/src/pages/Calendrier.js index bef41d7..39ad63c 100644 --- a/src/pages/Calendrier.js +++ b/src/pages/Calendrier.js @@ -39,6 +39,7 @@ useEffect(() =>{ const apiString = '/Contact/' + Session.get("idUser"); api.get(apiString).then((response) => { setContacts(response.data); + console.log("response.data",response.data); setSelectedContact(response.data[0].idcontact) }); diff --git a/src/pages/Repertoire.js b/src/pages/Repertoire.js index 6e235a4..8d34aab 100644 --- a/src/pages/Repertoire.js +++ b/src/pages/Repertoire.js @@ -6,6 +6,7 @@ import { TableContainer, Table, TableHead, TableBody, TableRow, TableCell } from import { Paper } from '@mui/material'; import { NavLink } from 'react-router-dom'; import { useNavigate } from 'react-router-dom'; +import Session from 'react-session-api'; const api = axios.create({ baseURL: 'http://localhost:8080' @@ -23,10 +24,12 @@ function Repertoire() { const [SearchResults, setSearchResults] = useState([]); const [customers, setCustomers] = useState([]); - useEffect(() => { - api.get('/Contact/AllWithCustomerName').then((response) => { + const apiString = '/Contact/' + Session.get("idUser"); + api.get(apiString).then((response) => { + setContacts(response.data); + console.log("response.data", response.data); setSearchTerm(response.data[0].idcontact); }); }, []); diff --git a/src/styles/components/_repertoire.scss b/src/styles/components/_repertoire.scss index 6d4110f..0cc9050 100644 --- a/src/styles/components/_repertoire.scss +++ b/src/styles/components/_repertoire.scss @@ -171,24 +171,19 @@ body { width: 100%; justify-content: space-between; + + .boutonAddContact { display: flex; justify-content: center; align-items: center; - width: 100%; - justify-content: space-between; - - .boutonAddContact { - display: flex; - justify-content: center; - align-items: center; - height: 40px; - min-width: 150px; - margin: 30px 30px; - border-radius: 25px; - box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); - text-decoration-line: none; - } + height: 40px; + min-width: 150px; + margin: 30px 30px; + border-radius: 25px; + box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); + text-decoration-line: none; + } .input_box { display: flex; From 58a13c102d65320a1e1184dc7478e6edfd8299ae Mon Sep 17 00:00:00 2001 From: Jeremy DUCOURTHIAL Date: Fri, 9 Dec 2022 20:56:17 +0100 Subject: [PATCH 8/9] Select sur calendrier fonctionnel --- server-api/api.js | 2 +- src/pages/Analyse.js | 1 - src/pages/Calendrier.js | 37 +++++++++++++++++-------------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/server-api/api.js b/server-api/api.js index da94fc8..f639d30 100644 --- a/server-api/api.js +++ b/server-api/api.js @@ -317,7 +317,7 @@ app.get('/Event/:iduser', (req, res) => { const iduser = req.params.iduser; - let sql = 'SELECT * FROM events e where e.iduserreceive = ?'; + let sql = 'SELECT e.date,e.starttime,e.endtime,e.comment FROM events e where e.iduserreceive = ?'; db.query(sql,[iduser], (err, result) => { if (err) throw err; diff --git a/src/pages/Analyse.js b/src/pages/Analyse.js index 2572fa5..1480ef5 100644 --- a/src/pages/Analyse.js +++ b/src/pages/Analyse.js @@ -132,7 +132,6 @@ const Analyse = () => { for(let i = 0; i < lineDatas.length; i++) { - console.log(lineDatas); dataH.labels[i] = lineDatas[i].month +"/" +lineDatas[i].year; dataH.datasets[0].data[i] = lineDatas[i].total; } diff --git a/src/pages/Calendrier.js b/src/pages/Calendrier.js index bef41d7..4134078 100644 --- a/src/pages/Calendrier.js +++ b/src/pages/Calendrier.js @@ -32,40 +32,37 @@ const localizer = dateFnsLocalizer({ function Calendrier(){ const [contacts, setContacts] = useState([]); - const [events, setEvents] = useState([]); const [selectedContact, setSelectedContact] = useState(1); + const [allEvents, setAllEvents] = useState([]); -useEffect(() =>{ - const apiString = '/Contact/' + Session.get("idUser"); - api.get(apiString).then((response) => { - setContacts(response.data); - setSelectedContact(response.data[0].idcontact) - }); - - const apiStringEvent = '/Event/' + Session.get("idUser"); - api.get(apiStringEvent).then((response) => { - setEvents(response.data); - }); + useEffect(() =>{ + const apiString = '/Contact/' + Session.get("idUser"); + api.get(apiString).then((response) => { + setContacts(response.data); + setSelectedContact(response.data[0].idcontact) + }); - events.forEach(event => { - const newEvent = { title: event.comment, start: new Date(event.date+" "+event.starttime), end: new Date(event.date+" "+event.endtime) }; - setAllEvents([...allEvents, newEvent]); - console.log("here"); - }); -}, []); + const apiStringEvent = '/Event/' + Session.get("idUser"); + api.get(apiStringEvent).then((response) => { + setAllEvents([]); + response.data.forEach(event => { + const newEvent = { title: event.comment, start: new Date(event.date+" "+event.starttime), end: new Date(event.date+" "+event.endtime) }; + setAllEvents(allEvents => [...allEvents, newEvent]); + }); + }); + }, []); const [theme, setTheme] = useState("light"); if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) { setTheme(localStorage.getItem("theme")) } + const [titre, setTitre] = useState(""); const [jour , setJour] = useState(new Date()); const [heureDebut, setHeureDebut] = useState(new Date()); const [heureFin, setHeureFin] = useState(new Date()); - const [allEvents, setAllEvents] = useState(events); - function handleAddEvent() { const newEvent = { title: titre, start: new Date(jour+" "+heureDebut), end: new Date(jour+" "+heureFin) }; const newEventBD = { date: jour,starttime: heureDebut,endtime: heureFin,comment: titre, idusersend: Session.get("idUser"),iduserreceive: Session.get("idUser"), idcontact: selectedContact}; From a031f86e11a22b3094680b903762edcc4da0a6c8 Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 9 Dec 2022 21:29:34 +0100 Subject: [PATCH 9/9] ajout contact OK --- src/components/Contact/AddContact.js | 97 +++++++++++++--------------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/src/components/Contact/AddContact.js b/src/components/Contact/AddContact.js index 8bf59aa..156e9ae 100644 --- a/src/components/Contact/AddContact.js +++ b/src/components/Contact/AddContact.js @@ -12,89 +12,84 @@ import Session from 'react-session-api'; const api = axios.create({ baseURL: 'http://localhost:8080' - }) +}) function AddContact() { - const [loginError, setLoginError] = useState(false); + const [loginError, setLoginError] = useState(false); const [entreprises, setEntreprises] = useState([]); const [selectedIdEntreprise, setSelectedIdEntreprise] = useState(1); - const [newContact, setNewContact] = useState([]); - - const navigate=useNavigate(); - - useEffect(() =>{ + const navigate = useNavigate(); + + useEffect(() => { api.get('/Entreprise/All').then((response) => { setEntreprises(response.data); - console.log(entreprises); }); }, []); - function handleChangeEntreprise(event){ + function handleChangeEntreprise(event) { setSelectedIdEntreprise(event.target.value); console.log("je suis dans handleChangeEntreprise"); }; - function checkAdd(event){ - + function checkAdd(event) { + event.preventDefault(); const formData = new FormData(event.currentTarget); const values = Object.fromEntries(formData.entries()); - setNewContact(values); - setNewContact(newContact => [...newContact, Session.get('idUser')]); - console.log("c'est le new contact " ,newContact); - api.get('/Contact/Exist/'+ values.phone).then((response) => { + api.get('/Contact/Exist/' + values.phone).then((response) => { const login = response.data; - if (login.length > 0){ + if (login.length > 0) { setLoginError(true); } else { setLoginError(false); - const newContact = [firstname:values.firstname, lastname:values.lastname, phone:values.phone, mail:values.email, iduser:Session.get('idUser'), idcustomer:values.selectedIdEntreprise]; - api.post('/Contact/Add', newContact).then (function(response) { + const newContact = { firstname: values.firstname, lastname: values.lastname, phone: values.phone, mail: values.mail, iduser: Session.get('idUser'), idcustomer: selectedIdEntreprise }; + api.post('/Contact/Add', newContact).then(function (response) { console.log(response.data); }); - console.log("c'est le new contact " ,newContact); - + navigate("/Repertoire"); } - navigate("/Repertoire"); + }); + }; - + + return (

Ajouter un nouveau contact

- - - -
-

Nom :

-

Prénom :

-

Téléphone :

-

Email :

-

Entreprise :

-
- - - - - - - - -
-

{loginError === true?"L'identifiant existe déja":''}

-
- - Retour -
- -
+
+ + +
+

Nom :

+

Prénom :

+

Téléphone :

+

Email :

+

Entreprise :

+
+ + + + + + + + +
+

{loginError === true ? "Le contact existe déja" : ''}

+
+ + Retour +
+
+
) }