|
|
|
@ -15,7 +15,7 @@ function Compte() {
|
|
|
|
|
const [theme, setTheme] = useState("light");
|
|
|
|
|
const nomInputRef = useRef();
|
|
|
|
|
const prenomInputRef = useRef();
|
|
|
|
|
const [modification, setModification] = useState(false);
|
|
|
|
|
const [modificationInfo, setModificationInfo] = useState(false);
|
|
|
|
|
const [selectedFile, setSelectedFile] = useState([]);
|
|
|
|
|
const [fileBase64String, setFileBase64String] = useState("");
|
|
|
|
|
const [lastName, setLastName] = useState("");
|
|
|
|
@ -25,6 +25,8 @@ function Compte() {
|
|
|
|
|
const [image, setImage] = useState("");
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
const [error, setError] = useState(null);
|
|
|
|
|
const [formData, setFormData] = useState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleFileChange(event) {
|
|
|
|
|
const file = event.target.files[0];
|
|
|
|
@ -54,21 +56,29 @@ function Compte() {
|
|
|
|
|
fileReader.readAsDataURL(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSubmit = (event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
// envoyer les données modifiées au serveur ici
|
|
|
|
|
api.put('/User/UpdateByClient/' + Session.get("idUser"), formData).then(response => {
|
|
|
|
|
// Traitez la réponse du serveur
|
|
|
|
|
});
|
|
|
|
|
setModificationInfo(false);
|
|
|
|
|
setLastName(formData.lastName);
|
|
|
|
|
setFirstName(formData.firstName);
|
|
|
|
|
setPhone(formData.phone);
|
|
|
|
|
setMail(formData.mail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleChange = (event) => {
|
|
|
|
|
setFormData({...formData, [event.target.name]: event.target.value });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) {
|
|
|
|
|
setTheme(localStorage.getItem("theme"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*const [file, setFile] = useState();
|
|
|
|
|
function handleChange(e) {
|
|
|
|
|
setFile(URL.createObjectURL(e.target.files[0]));
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
const modificationHandler = () => {
|
|
|
|
|
setModification((modification) => !modification)
|
|
|
|
|
console.log(modification)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
|
@ -82,27 +92,16 @@ function Compte() {
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
function handleChangeLastName(event) {
|
|
|
|
|
//setLastName(event.target.value);
|
|
|
|
|
const enteredLastName = nomInputRef.current.value;
|
|
|
|
|
|
|
|
|
|
//mettre à jour le state
|
|
|
|
|
setLastName({
|
|
|
|
|
...lastName,
|
|
|
|
|
"nom": enteredLastName,
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setFormData({
|
|
|
|
|
firstName: firstName,
|
|
|
|
|
lastName: lastName,
|
|
|
|
|
mail: mail,
|
|
|
|
|
phone: phone,
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
}, [null, modificationInfo]);
|
|
|
|
|
|
|
|
|
|
function handleChangeFirstName(event) {
|
|
|
|
|
//setFirstName(event.target.value);
|
|
|
|
|
const enteredFirstName = prenomInputRef.current.value;
|
|
|
|
|
|
|
|
|
|
//mettre à jour le state
|
|
|
|
|
setFirstName({
|
|
|
|
|
...firstName,
|
|
|
|
|
"prenom": enteredFirstName,
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<body className={theme}>
|
|
|
|
@ -119,7 +118,7 @@ function Compte() {
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bas_de_page">
|
|
|
|
|
<NavigationDashboard />
|
|
|
|
|
<div className="Compte">
|
|
|
|
|
<form className="Compte" onSubmit={handleSubmit}>
|
|
|
|
|
<div className="name_picture">
|
|
|
|
|
<div className="picture">
|
|
|
|
|
<div id="display_image">
|
|
|
|
@ -132,14 +131,38 @@ function Compte() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="name">
|
|
|
|
|
<div className="presentationNom">
|
|
|
|
|
<p id="texte" className="def">Nom Complet :</p>
|
|
|
|
|
{!modification && <p>{firstName + " " + lastName}</p>}
|
|
|
|
|
{modification && (<input type="text" value={firstName + " " + lastName} onChange={e => { handleChangeLastName(e); handleChangeFirstName(e) }} ref={nomInputRef + prenomInputRef}></input>)}
|
|
|
|
|
{modificationInfo ?
|
|
|
|
|
<div>
|
|
|
|
|
<input
|
|
|
|
|
name="firstName"
|
|
|
|
|
placeholder="firstName"
|
|
|
|
|
value={formData.firstName}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
/>
|
|
|
|
|
<input
|
|
|
|
|
name="lastName"
|
|
|
|
|
placeholder="lastName"
|
|
|
|
|
value={formData.lastName}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
:
|
|
|
|
|
<p>{firstName + " " + lastName}</p>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div className='bouton_submit'>
|
|
|
|
|
<button id="bouton" className="bouton_modifierNom" type="submit" onClick={modificationHandler}>{!modification ? "Modifier" : "Envoyer"}</button>
|
|
|
|
|
{modificationInfo ?
|
|
|
|
|
<div>
|
|
|
|
|
<div id="bouton" className="bouton_modifierNom" onClick={() => setModificationInfo(false)}>Annuler</div>
|
|
|
|
|
<button id="bouton" className="bouton_modifierNom" type='submit' >Valider</button>
|
|
|
|
|
</div>
|
|
|
|
|
:
|
|
|
|
|
<div id="bouton" className="bouton_modifierNom" onClick={() => setModificationInfo(true)}>Modifier</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -147,7 +170,16 @@ function Compte() {
|
|
|
|
|
<p className="description">Informations personnelles</p>
|
|
|
|
|
<div className="parti_mail">
|
|
|
|
|
<p className="def">Mail :</p>
|
|
|
|
|
<input id="mail" value={mail} name="mail" className="mail" type="text" disabled />
|
|
|
|
|
{modificationInfo ?
|
|
|
|
|
<input
|
|
|
|
|
name="mail"
|
|
|
|
|
placeholder={mail}
|
|
|
|
|
value={formData.mail}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
/>
|
|
|
|
|
:
|
|
|
|
|
<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>
|
|
|
|
@ -155,7 +187,17 @@ function Compte() {
|
|
|
|
|
</div>
|
|
|
|
|
<div className="parti_tel">
|
|
|
|
|
<p className="def">Tel :</p>
|
|
|
|
|
<input id="tel" value={phone} name="tel" className="tel" type="text" disabled />
|
|
|
|
|
{modificationInfo ?
|
|
|
|
|
<input
|
|
|
|
|
name="phone"
|
|
|
|
|
placeholder={phone}
|
|
|
|
|
value={formData.phone}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
/>
|
|
|
|
|
:
|
|
|
|
|
<input id="phone" value={phone} name="tel" className="tel" type="text" disabled />
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="infoEntreprise">
|
|
|
|
@ -173,7 +215,7 @@ function Compte() {
|
|
|
|
|
<p className="nbClient">200</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</body >
|
|
|
|
|