From 81c10038b88a13ef2672618d3565975d8f746241 Mon Sep 17 00:00:00 2001 From: anwesha Date: Tue, 14 May 2024 13:29:41 -0400 Subject: [PATCH] refac:some UI of MY_Account feature --- .idea/.gitignore | 5 +++++ .idea/e-commerce_website.iml | 12 ++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ src/components/AccountDetails/Account.js | 20 +++++++++++++++++--- 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/e-commerce_website.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/e-commerce_website.iml b/.idea/e-commerce_website.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/e-commerce_website.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..281a9e2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/components/AccountDetails/Account.js b/src/components/AccountDetails/Account.js index e149008..3230cde 100644 --- a/src/components/AccountDetails/Account.js +++ b/src/components/AccountDetails/Account.js @@ -6,6 +6,7 @@ import imageBackground from "../../assets/images/slider-1.png" import pfp from "../../assets/images/pfp.jpg" import {useEffect, useState} from "react"; import {getDownloadURL, ref, uploadBytes} from "firebase/storage"; +import { useNavigate} from "react-router-dom" import { addDoc, collection, @@ -22,6 +23,7 @@ import { import {db, storage} from "../../firebase"; import {nanoid} from "nanoid"; import {useParams} from "react-router-dom"; +import {FontAwesomeIcon } from "@fortawesome/react-fontawesome"; export function Account(){ @@ -36,6 +38,8 @@ export function Account(){ + + useEffect(()=>{ (async ()=>{ const docref = doc(db,"users", `${user_uid? user_uid : nanoid()}`) @@ -89,13 +93,20 @@ export function Account(){ } - const updateUser = async () =>{ + const updateUser = async (e) =>{ + e.preventDefault() + try { + const imageRef = ref(storage, `AccountImage/${localStorage.getItem("uid")}`); + await uploadBytes(imageRef, file); + const imageUrl = await getDownloadURL(imageRef); + + await updateDoc(doc(db,"users", user_uid),{ Name : name, Email : email, Address : address, - photo : file + photo : imageUrl }) }catch (err){ console.log(err) @@ -105,7 +116,10 @@ export function Account(){ return( <> -
+
+

+ + My Account