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 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',
password: 'Jeremy1234',
database: 'crm-database'

@ -17,10 +17,12 @@
"body-parser": "^1.20.1",
"corps": "^0.1.0",
"cors": "^2.8.5",
"crypto-js": "^4.1.1",
"express": "^4.18.2",
"fullcalendar": "^5.11.3",
"googleapis": "^105.0.0",
"mysql": "^2.18.1",
"nodemailer": "^6.8.0",
"parser": "^0.1.4"
},
"devDependencies": {
@ -1401,6 +1403,11 @@
"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": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
@ -2286,6 +2293,14 @@
"integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==",
"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": {
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz",
@ -3967,6 +3982,11 @@
"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": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
@ -4636,6 +4656,11 @@
"integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==",
"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": {
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz",

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

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

@ -1,6 +1,6 @@
import { Component } from '@fullcalendar/core';
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 img1 from '../img/logo_personEntouré.svg';
import axios from 'axios'
@ -12,7 +12,20 @@ const api = axios.create({
function Compte() {
const [theme, setTheme] = useState("light");
const nomInputRef = useRef();
const prenomInputRef = useRef();
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) {
setTheme(localStorage.getItem("theme"))
}
@ -32,17 +45,54 @@ function Compte() {
const [firstName, setFirstName] = useState("");
const [phone, setPhone] = useState("");
const [mail, setMail] = useState("");
const [image, setImage] = useState("");
useEffect(() =>{
useEffect(() => {
const apiString = '/User/Id/' + Session.get("idUser");
api.get(apiString).then((response) => {
setLastName(response.data[0].lastname);
setFirstName(response.data[0].firstname);
setPhone(response.data[0].phone);
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 (
<body className={theme}>
@ -62,22 +112,16 @@ function Compte() {
<div className="name_picture">
<div className="picture">
<div id="display_image">
<img src={img1} srcSet={file} id="img" className="img"></img>
</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>
<img src={img1} srcSet={image} id="img" className="img" />
<div> <input id="fileUpload" type="file" onChange={e => { convert2base64(e); handleChange(e); handleImageAdding() }}></input></div>
</div>
<label className="fileUpload" htmlFor="fileUpload">Ajoutez votre photo</label>
</div>
<div className="name">
<div className="presentationNom">
<p id="texte" className="def">Nom Complet :</p>
<p>{}</p>
<input id="texte" value={firstName +" "+ lastName} name="texte" className="texte" type="text" disabled/>
{!modification && <p>{firstName + " " + lastName}</p>}
{modification && (<input type="text" value={firstName + " " + lastName} onChange={e => {handleChangeLastName(e); handleChangeFirstName(e)}} ref={nomInputRef + prenomInputRef}></input>)}
</div>
<div className='bouton_submit'>
<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>
<div className="parti_mail">
<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 className="parti_pays">
<p className="def">Pays ou Région :</p>
@ -96,7 +140,7 @@ function Compte() {
</div>
<div className="parti_tel">
<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 className="infoEntreprise">
@ -117,7 +161,7 @@ function Compte() {
</div>
</div>
</div>
</body>
</body >
);
};

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