commit pour la conversion d'image en base 64

master
Théo DUPIN 2 years ago
parent ac96216ab7
commit db343115fe

@ -4,7 +4,7 @@ const cors=require("cors");
const bodyparser = require('body-parser'); const bodyparser = require('body-parser');
const db = mysql.createConnection({ const db = mysql.createConnection({
host: 'lfbn-cle-1-568-58.w92-157.abo.wanadoo.fr', host: 'lfbn-cle-1-608-214.w92-157.abo.wanadoo.fr',
user: 'crmuser', user: 'crmuser',
password: 'Jeremy1234', password: 'Jeremy1234',
database: 'crm-database' database: 'crm-database'

@ -17,10 +17,12 @@
"body-parser": "^1.20.1", "body-parser": "^1.20.1",
"corps": "^0.1.0", "corps": "^0.1.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"crypto-js": "^4.1.1",
"express": "^4.18.2", "express": "^4.18.2",
"fullcalendar": "^5.11.3", "fullcalendar": "^5.11.3",
"googleapis": "^105.0.0", "googleapis": "^105.0.0",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"nodemailer": "^6.8.0",
"parser": "^0.1.4" "parser": "^0.1.4"
}, },
"devDependencies": { "devDependencies": {
@ -1401,6 +1403,11 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
},
"node_modules/csstype": { "node_modules/csstype": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
@ -2286,6 +2293,14 @@
"integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==",
"peer": true "peer": true
}, },
"node_modules/nodemailer": {
"version": "6.8.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.8.0.tgz",
"integrity": "sha512-EjYvSmHzekz6VNkNd12aUqAco+bOkRe3Of5jVhltqKhEsjw/y0PYPJfp83+s9Wzh1dspYAkUW/YNQ350NATbSQ==",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/nodemon": { "node_modules/nodemon": {
"version": "2.0.20", "version": "2.0.20",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz",
@ -3967,6 +3982,11 @@
"yaml": "^1.10.0" "yaml": "^1.10.0"
} }
}, },
"crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
},
"csstype": { "csstype": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
@ -4636,6 +4656,11 @@
"integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==",
"peer": true "peer": true
}, },
"nodemailer": {
"version": "6.8.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.8.0.tgz",
"integrity": "sha512-EjYvSmHzekz6VNkNd12aUqAco+bOkRe3Of5jVhltqKhEsjw/y0PYPJfp83+s9Wzh1dspYAkUW/YNQ350NATbSQ=="
},
"nodemon": { "nodemon": {
"version": "2.0.20", "version": "2.0.20",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz",

@ -17,10 +17,12 @@
"body-parser": "^1.20.1", "body-parser": "^1.20.1",
"corps": "^0.1.0", "corps": "^0.1.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"crypto-js": "^4.1.1",
"express": "^4.18.2", "express": "^4.18.2",
"fullcalendar": "^5.11.3", "fullcalendar": "^5.11.3",
"googleapis": "^105.0.0", "googleapis": "^105.0.0",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"nodemailer": "^6.8.0",
"parser": "^0.1.4" "parser": "^0.1.4"
}, },
"description": "", "description": "",

@ -17,8 +17,7 @@ const locales = {
parse, parse,
startOfWeek, startOfWeek,
getDay, getDay,
locales, locales,
}); });
const events = [ const events = [

@ -1,6 +1,6 @@
import { Component } from '@fullcalendar/core'; import { Component } from '@fullcalendar/core';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import NavigationDashboard from '../components/NavigationDashboard'; import NavigationDashboard from '../components/NavigationDashboard';
import img1 from '../img/logo_personEntouré.svg'; import img1 from '../img/logo_personEntouré.svg';
import axios from 'axios' import axios from 'axios'
@ -12,7 +12,20 @@ const api = axios.create({
function Compte() { function Compte() {
const [theme, setTheme] = useState("light"); const [theme, setTheme] = useState("light");
const nomInputRef = useRef();
const prenomInputRef = useRef();
const [modification, setModification] = useState(false); const [modification, setModification] = useState(false);
const convert2base64 = e => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onloadend = () => {
setImage(reader.result);
}
reader.readAsDataURL(file);
};
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"))
} }
@ -32,17 +45,54 @@ function Compte() {
const [firstName, setFirstName] = useState(""); const [firstName, setFirstName] = useState("");
const [phone, setPhone] = useState(""); const [phone, setPhone] = useState("");
const [mail, setMail] = useState(""); const [mail, setMail] = useState("");
const [image, setImage] = useState("");
useEffect(() =>{ useEffect(() => {
const apiString = '/User/Id/' + Session.get("idUser"); const apiString = '/User/Id/' + Session.get("idUser");
api.get(apiString).then((response) => { api.get(apiString).then((response) => {
setLastName(response.data[0].lastname); setLastName(response.data[0].lastname);
setFirstName(response.data[0].firstname); setFirstName(response.data[0].firstname);
setPhone(response.data[0].phone); setPhone(response.data[0].phone);
setMail(response.data[0].mail); setMail(response.data[0].mail);
setImage(response.data[0].image);
}); });
}, []); }, []);
const handleImageAdding = (e) => {
const bdd = { image };
fetch('http://localhost:8080', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(bdd)
})
.then(() => {
console.log('Image ajoutée');
})
}
function handleChangeLastName(event) {
//setLastName(event.target.value);
const enteredLastName = nomInputRef.current.value;
//mettre à jour le state
setLastName({
...lastName,
"nom": enteredLastName,
})
};
function handleChangeFirstName(event) {
//setFirstName(event.target.value);
const enteredFirstName = prenomInputRef.current.value;
//mettre à jour le state
setFirstName({
...firstName,
"prenom": enteredFirstName,
})
};
return ( return (
<body className={theme}> <body className={theme}>
@ -62,22 +112,16 @@ function Compte() {
<div className="name_picture"> <div className="name_picture">
<div className="picture"> <div className="picture">
<div id="display_image"> <div id="display_image">
<img src={img1} srcSet={file} id="img" className="img"></img> <img src={img1} srcSet={image} id="img" className="img" />
</div> <div> <input id="fileUpload" type="file" onChange={e => { convert2base64(e); handleChange(e); handleImageAdding() }}></input></div>
<div className='bouton_submit'>
<input type="file" name="fileUpload" id="input" accept="image/" onChange={handleChange} />
<div className="label">
<label className="fileUpload" htmlFor="input">
Ajoutez votre photo
</label>
</div>
</div> </div>
<label className="fileUpload" htmlFor="fileUpload">Ajoutez votre photo</label>
</div> </div>
<div className="name"> <div className="name">
<div className="presentationNom"> <div className="presentationNom">
<p id="texte" className="def">Nom Complet :</p> <p id="texte" className="def">Nom Complet :</p>
<p>{}</p> {!modification && <p>{firstName + " " + lastName}</p>}
<input id="texte" value={firstName +" "+ lastName} name="texte" className="texte" type="text" disabled/> {modification && (<input type="text" value={firstName + " " + lastName} onChange={e => {handleChangeLastName(e); handleChangeFirstName(e)}} ref={nomInputRef + prenomInputRef}></input>)}
</div> </div>
<div className='bouton_submit'> <div className='bouton_submit'>
<button id="bouton" className="bouton_modifierNom" type="submit" onClick={modificationHandler}>{!modification ? "Modifier" : "Envoyer"}</button> <button id="bouton" className="bouton_modifierNom" type="submit" onClick={modificationHandler}>{!modification ? "Modifier" : "Envoyer"}</button>
@ -88,7 +132,7 @@ function Compte() {
<p className="description">Informations personnel</p> <p className="description">Informations personnel</p>
<div className="parti_mail"> <div className="parti_mail">
<p className="def">Mail :</p> <p className="def">Mail :</p>
<input id="mail" value={mail} name="mail" className="mail" type="text" disabled/> <input id="mail" value={mail} name="mail" className="mail" type="text" disabled />
</div> </div>
<div className="parti_pays"> <div className="parti_pays">
<p className="def">Pays ou Région :</p> <p className="def">Pays ou Région :</p>
@ -96,7 +140,7 @@ function Compte() {
</div> </div>
<div className="parti_tel"> <div className="parti_tel">
<p className="def">Tel :</p> <p className="def">Tel :</p>
<input id="tel" value={phone} name="tel" className="tel" type="text" disabled/> <input id="tel" value={phone} name="tel" className="tel" type="text" disabled />
</div> </div>
</div> </div>
<div className="infoEntreprise"> <div className="infoEntreprise">
@ -117,7 +161,7 @@ function Compte() {
</div> </div>
</div> </div>
</div> </div>
</body> </body >
); );
}; };

@ -1,5 +1,3 @@
body { body {
.page_compte { .page_compte {
@ -8,7 +6,7 @@ body {
justify-content: space-evenly; justify-content: space-evenly;
width: auto; width: auto;
height: 100vh; height: 100vh;
.haut_de_page { .haut_de_page {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -18,7 +16,7 @@ body {
height: 10%; height: 10%;
align-items: center; align-items: center;
margin: 10px 10px 5px 10px; margin: 10px 10px 5px 10px;
background: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.3);
border-radius: 15px; border-radius: 15px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
@ -28,7 +26,7 @@ body {
.titre { .titre {
font-size: 40px; font-size: 40px;
} }
.rechLogo { .rechLogo {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -40,16 +38,16 @@ body {
width: 100px; width: 100px;
height: 100px; height: 100px;
} }
} }
} }
.bas_de_page { .bas_de_page {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
width: auto; width: auto;
height: 86%; height: 86%;
.nav_bar_verticale { .nav_bar_verticale {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -108,7 +106,7 @@ body {
border: none; border: none;
cursor: pointer; cursor: pointer;
.logo_nav_bar{ .logo_nav_bar {
display: flex; display: flex;
margin: 10px; margin: 10px;
height: 50px; height: 50px;
@ -116,8 +114,8 @@ body {
} }
} }
} }
.Compte { .Compte {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -170,17 +168,17 @@ body {
object-fit: cover; object-fit: cover;
} }
} }
.figure{ .figure {
width: 45%; width: 45%;
} }
.img{ .img {
width: 100%; width: 100%;
} }
.bouton_submit {
/*.bouton_submit {
display: flex; display: flex;
margin-left: 30px; margin-left: 30px;
align-items: center; align-items: center;
@ -200,200 +198,206 @@ body {
background-color: lightgrey; background-color: lightgrey;
} }
}*/ }*/
}
} }
}
.name { .name {
display: flex;
flex-direction: row;
justify-content: space-between;
margin: 0 25px;
.presentationNom {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-evenly;
margin: 0 25px;
.presentationNom { .def {
display: flex; display: flex;
flex-direction: row; font-weight: bold;
justify-content: space-evenly; }
.def {
display: flex;
font-weight: bold;
}
.nom { .nom {
display: flex; display: flex;
margin-left: 125px;; margin-left: 125px;
} ;
} }
.bouton_submit { .texte {
display: flex; display: flex;
flex-wrap: wrap;
.bouton_modifierNom { margin-left: 125px;
width: 75px; }
height: 20px; }
background-color: rgb(190, 189, 189);
border-radius: 5px; .bouton_submit {
border-radius: 5px; display: flex;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
cursor: pointer; .bouton_modifierNom {
width: 75px;
&:hover{ height: 20px;
background-color: lightgrey; background-color: rgb(190, 189, 189);
} border-radius: 5px;
border-radius: 5px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
cursor: pointer;
&:hover {
background-color: lightgrey;
} }
} }
} }
} }
}
.infoPerso {
display: flex;
flex-direction: column;
justify-content: space-evenly;
margin-left: 13px;
margin-right: 13px;
width: auto;
height: 30%;
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
backdrop-filter: blur(3px);
-webkit-backdrop-filter: blur(15px);
.infoPerso { .description {
display: flex; display: flex;
flex-direction: column; margin: 0 25px;
justify-content: space-evenly; border-bottom: 1px solid grey;
margin-left: 13px; padding: 0 0 10px 0;
margin-right: 13px; font-weight: bold;
width: auto; }
height: 30%;
background: rgba(255, 255, 255, 0.1); .parti_mail {
border-radius: 15px; display: flex;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); flex-direction: row;
backdrop-filter: blur(3px); margin: 0 25px;
-webkit-backdrop-filter: blur(15px); border-bottom: 1px solid grey;
padding: 0 0 15px 0;
.description { .def {
display: flex; display: flex;
margin: 0 25px;
border-bottom: 1px solid grey;
padding: 0 0 10px 0;
font-weight: bold; font-weight: bold;
} }
.parti_mail { .mail {
display: flex; display: flex;
flex-direction: row; margin-left: 199px;
margin: 0 25px; }
border-bottom: 1px solid grey; }
padding: 0 0 15px 0;
.def { .parti_pays {
display: flex; display: flex;
font-weight: bold; flex-direction: row;
} margin: 0 25px;
border-bottom: 1px solid grey;
padding: 0 0 15px 0;
.mail { .def {
display: flex; display: flex;
margin-left: 199px; font-weight: bold;
}
} }
.parti_pays { .pays_region {
display: flex; display: flex;
flex-direction: row; margin-left: 110px;
margin: 0 25px; }
border-bottom: 1px solid grey; }
padding: 0 0 15px 0;
.def { .parti_tel {
display: flex; display: flex;
font-weight: bold; flex-direction: row;
} margin: 0 25px;
.pays_region { .def {
display: flex; display: flex;
margin-left: 110px; font-weight: bold;
}
} }
.parti_tel { .tel {
display: flex; display: flex;
flex-direction: row; margin-left: 207px;
margin: 0 25px;
.def {
display: flex;
font-weight: bold;
}
.tel {
display: flex;
margin-left: 207px;
}
} }
} }
}
.infoEntreprise { .infoEntreprise {
display: flex;
flex-direction: column;
justify-content: space-evenly;
margin: 13px;
width: auto;
height: 30%;
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
backdrop-filter: blur(3px);
-webkit-backdrop-filter: blur(15px);
.description {
display: flex; display: flex;
flex-direction: column; margin: 0 25px;
justify-content: space-evenly; border-bottom: 1px solid grey;
margin: 13px; padding: 0 0 10px 0;
width: auto; font-weight: bold;
height: 30%; }
background: rgba(255, 255, 255, 0.1); .parti_name {
border-radius: 15px; display: flex;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); flex-direction: row;
backdrop-filter: blur(3px); margin: 0 25px;
-webkit-backdrop-filter: blur(15px); border-bottom: 1px solid grey;
padding: 0 0 15px 0;
.description { .def {
display: flex; display: flex;
margin: 0 25px;
border-bottom: 1px solid grey;
padding: 0 0 10px 0;
font-weight: bold; font-weight: bold;
} }
.parti_name { .name {
display: flex; display: flex;
flex-direction: row; margin-left: 92px;
margin: 0 25px; }
border-bottom: 1px solid grey; }
padding: 0 0 15px 0;
.def { .parti_secteurAct {
display: flex; display: flex;
font-weight: bold; flex-direction: row;
} margin: 0 25px;
border-bottom: 1px solid grey;
padding: 0 0 15px 0;
.name { .def {
display: flex; display: flex;
margin-left: 92px; font-weight: bold;
}
} }
.parti_secteurAct{ .secteurAct {
display: flex; display: flex;
flex-direction: row; margin-left: 98px;
margin: 0 25px; }
border-bottom: 1px solid grey; }
padding: 0 0 15px 0;
.def { .parti_nbClient {
display: flex; display: flex;
font-weight: bold; flex-direction: row;
} margin: 0 25px;
.secteurAct { .def {
display: flex; display: flex;
margin-left: 98px; font-weight: bold;
}
} }
.parti_nbClient { .nbClient {
display: flex; display: flex;
flex-direction: row; margin-left: 115px;
margin: 0 25px;
.def {
display: flex;
font-weight: bold;
}
.nbClient {
display: flex;
margin-left: 115px;
}
} }
} }
} }
@ -401,22 +405,23 @@ body {
} }
} }
#input[type="file"] { #fileUpload[type="file"] {
display: none; display: none;
} }
.fileUpload{ .fileUpload {
width: 100%; width: 100%;
margin-top: 1rem; margin-top: 1rem;
display: flex; display: flex;
flex-direction: column; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin: auto; margin-left: 20px;
margin-top: 40px;
width: 150px; width: 150px;
height: 50px; height: 50px;
color: white; color: white;
border-radius: 10px; border-radius: 10px;
background-color: $xiketic; background-color: $xiketic;
cursor: pointer; cursor: pointer;
} }
Loading…
Cancel
Save