Théo DUPIN 3 years ago
commit 8a29dab79c

28655
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -76,7 +76,7 @@ app.get('/User/Auth/:login/:pwd', (req, res) => {
const login = req.params.login; const login = req.params.login;
const pwd = req.params.pwd; const pwd = req.params.pwd;
let sql = 'SELECT login, password = ? as result FROM users WHERE login = ?'; let sql = 'SELECT iduser,login, password = ? as result FROM users WHERE login = ?';
db.query(sql, [pwd, login], (err, result) => { db.query(sql, [pwd, login], (err, result) => {
if (err) throw err; if (err) throw err;
@ -130,9 +130,9 @@ app.get('/Sale/Pie/:iduser/:month/:year', (req, res) => {
const iduser = req.params.iduser; const iduser = req.params.iduser;
const month = req.params.month; const month = req.params.month;
const year = req.params.year; const year = req.params.year;
let sql = 'SELECT DISTINCT SUM(s.amount) as total,cu.name FROM sales s,customers cu,contacts co WHERE co.iduser = ? AND co.idcustomer = cu.idcustomer AND cu.idcustomer = s.idcustomer AND s.month >= ? AND s.year >= ? GROUP BY cu.name ORDER BY total DESC'; let sql = 'SELECT DISTINCT SUM(s.amount) as total,cu.name FROM sales s,customers cu,contacts co WHERE co.iduser = ? AND co.idcustomer = cu.idcustomer AND cu.idcustomer = s.idcustomer AND ((s.month >= ? AND s.year = ?) OR s.year > ?) GROUP BY cu.name ORDER BY total DESC';
db.query(sql, [iduser,month,year], (err, result) => { db.query(sql, [iduser,month,year,year], (err, result) => {
if (err) throw err; if (err) throw err;
console.log(result); console.log(result);

@ -23,6 +23,11 @@ const NavigationAdmin = (props) => {
<button id="bouton_devis" className="bouton" type="button" value="Devis">Devis</button> <button id="bouton_devis" className="bouton" type="button" value="Devis">Devis</button>
</NavLink> </NavLink>
</div> </div>
<div className="BoutonDeco">
<NavLink className="déconnexion" to="/">
<button id="bouton_deco" className="bouton" type="button" value="Déco">Déconnexion</button>
</NavLink>
</div>
</div> </div>
); );
}; };

@ -6,6 +6,7 @@ import { Pie } from "react-chartjs-2";
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js'; import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js';
import { setDefaultLocale } from 'react-datepicker'; import { setDefaultLocale } from 'react-datepicker';
import { private_excludeVariablesFromRoot } from '@mui/material'; import { private_excludeVariablesFromRoot } from '@mui/material';
import Session from 'react-session-api';
ChartJS.register(ArcElement, Tooltip, Legend); ChartJS.register(ArcElement, Tooltip, Legend);
@ -14,6 +15,7 @@ const api = axios.create({
}) })
const Analyse = () => { const Analyse = () => {
const [theme, setTheme] = useState("light"); const [theme, setTheme] = useState("light");
if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) { if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) {
setTheme(localStorage.getItem("theme")) setTheme(localStorage.getItem("theme"))
@ -29,7 +31,7 @@ const Analyse = () => {
const year = date.getFullYear(); const year = date.getFullYear();
const month = (date.getMonth() + 1); const month = (date.getMonth() + 1);
const apiString = '/Sale/Pie/' + 41 + '/' + month + '/' + year; const apiString = '/Sale/Pie/' + Session.get("idUser") + '/' + month + '/' + year;
api.get(apiString).then((response) => { api.get(apiString).then((response) => {
// Don't work !! // Don't work !!

@ -5,6 +5,7 @@ import Admin from './Admin_create.js'
import Dashboard from './Dashboard.js' import Dashboard from './Dashboard.js'
import Admin_list from './Admin_list.js'; import Admin_list from './Admin_list.js';
import Chargement from './Chargement.js'; import Chargement from './Chargement.js';
import Session from 'react-session-api';
const api = axios.create({ const api = axios.create({
baseURL: 'http://localhost:8080' baseURL: 'http://localhost:8080'
@ -47,11 +48,14 @@ function Connexion() {
const apiString = '/User/Auth/' + login + "/" + CryptoJS.SHA256(password).toString(CryptoJS.enc.Hex); const apiString = '/User/Auth/' + login + "/" + CryptoJS.SHA256(password).toString(CryptoJS.enc.Hex);
api.get(apiString).then((response) => { api.get(apiString).then((response) => {
const users = response.data; const users = response.data;
console.log(response.data.length); //console.log(response.data.length);
console.log(users.length); //console.log(users.length);
if (users.length > 0) if (users.length > 0)
if (users[0].result === 1) if (users[0].result === 1)
{
setAuth("Succeed"); setAuth("Succeed");
Session.set("idUser", (users[0].iduser));
}
else else
setAuth("Failed"); setAuth("Failed");
else else
@ -72,15 +76,15 @@ function Connexion() {
const apiString = '/User/role/' + login; const apiString = '/User/role/' + login;
api.get(apiString).then((response) => { api.get(apiString).then((response) => {
const role = response.data; const role = response.data;
console.log("Role: " + role[0].idRole); //console.log("Role: " + role[0].idRole);
console.log("longueur role: " + role.length); //console.log("longueur role: " + role.length);
if (role.length > 0){ if (role.length > 0){
setRole(role[0].idRole); setRole(role[0].idRole);
} }
else else
setRole(-1); setRole(-1);
}); });
console.log("RoleUser: " + roleUser); //console.log("RoleUser: " + roleUser);
if (roleUser === 4) if (roleUser === 4)
return (<Admin_list />); return (<Admin_list />);
else if (roleUser === 1) else if (roleUser === 1)

@ -28,6 +28,7 @@ body {
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
align-items: center; align-items: center;
height: 20%;
.logo { .logo {
max-width: 150px; max-width: 150px;
@ -39,8 +40,7 @@ body {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-evenly; justify-content: space-evenly;
height: 450px; height: 50%;
margin-bottom: 180px;
.create_user { .create_user {
display: flex; display: flex;
@ -69,6 +69,19 @@ body {
text-decoration: none; text-decoration: none;
align-self: center; align-self: center;
} }
}
.BoutonDeco {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 15%;
.déconnexion {
text-decoration: none;
}
}
.bouton { .bouton {
display: flex; display: flex;
@ -95,9 +108,6 @@ body {
} }
} }
} }
}
.Titre_Formulaire{ .Titre_Formulaire{
display: flex; display: flex;

Loading…
Cancel
Save