From ff4f3194055df317aba588fa17898d3add2ad8aa Mon Sep 17 00:00:00 2001 From: Darius BERTRAND Date: Tue, 17 Jan 2023 14:51:10 +0100 Subject: [PATCH] avancement --- .../Configurations/ConfigurationDuProfil.js | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js index b79b8ac7..7f815912 100644 --- a/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js +++ b/Site Web/client/src/components/Configurations/ConfigurationDuProfil.js @@ -13,8 +13,8 @@ const ConfigurationDuProfil = ()=>{ const userData = useSelector((state) => state.user.user); const [pseudo, setPseudo] = useState(userData.pseudo); - const[userPicture, setUserPicture] = useState(userData.picture) - const [tmpImage, setTmpImage] =useState('') + const[userPicture, setUserPicture] = useState(userData.picture); + const [tmpImage, setTmpImage] =useState(PLUS); const [displayAdd, setDisplayAdd] = useState(false); const dispatch = useDispatch(); @@ -23,11 +23,23 @@ const ConfigurationDuProfil = ()=>{ setDisplayAdd(false); } const handleLoadFile=(e)=>{ - var image = document.getElementById("output"); - image.src = URL.createObjectURL(e.target.files[0]); - setTmpImage(image.src); + const file=e.target.files[0]; + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => { + setTmpImage({ + data: reader.result, + contentType: file.type, + }); }; + }; + + + const handleTPM =()=> { + console.log("test"); + console.log(tmpImage); + } const handleUpdate = async (e) => { console.log(userPicture) e.preventDefault(); @@ -124,13 +136,13 @@ const ConfigurationDuProfil = ()=>{ Changer - {/* onChange={(e)=> setTmpImage(e.target.files[0].name)} */} - + {/*onChange={handleLoadFile} onChange={(e)=> setTmpImage(e.target.files[0].name)} */} +
- +