Théo DUPIN 3 years ago
commit 8a29dab79c

29333
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 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) => {
if (err) throw err;
@ -130,9 +130,9 @@ app.get('/Sale/Pie/:iduser/:month/:year', (req, res) => {
const iduser = req.params.iduser;
const month = req.params.month;
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;
console.log(result);

@ -23,6 +23,11 @@ const NavigationAdmin = (props) => {
<button id="bouton_devis" className="bouton" type="button" value="Devis">Devis</button>
</NavLink>
</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>
);
};

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

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

@ -28,6 +28,7 @@ body {
flex-direction: column;
justify-content: space-around;
align-items: center;
height: 20%;
.logo {
max-width: 150px;
@ -39,8 +40,7 @@ body {
display: flex;
flex-direction: column;
justify-content: space-evenly;
height: 450px;
margin-bottom: 180px;
height: 50%;
.create_user {
display: flex;
@ -69,35 +69,45 @@ body {
text-decoration: none;
align-self: center;
}
.bouton {
display: flex;
justify-content: center;
align-items: center;
width: 150px;
height: 60px;
font-size: 17px;
font-weight: bold;
transition: 1s box-shadow;
border: none;
cursor: pointer;
color: white;
background-color: grey;
border-radius: 15px;
}
&:hover {
color: white;
background-color: rgba(114, 114, 114, 0.371);
}
.BoutonDeco {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 15%;
&:active {
background-color: rgba(68, 68, 68, 0.972);
}
.déconnexion {
text-decoration: none;
}
}
}
.bouton {
display: flex;
justify-content: center;
align-items: center;
width: 150px;
height: 60px;
font-size: 17px;
font-weight: bold;
transition: 1s box-shadow;
border: none;
cursor: pointer;
color: white;
background-color: grey;
border-radius: 15px;
&:hover {
color: white;
background-color: rgba(114, 114, 114, 0.371);
}
&:active {
background-color: rgba(68, 68, 68, 0.972);
}
}
}
.Titre_Formulaire{
display: flex;

Loading…
Cancel
Save