-
+
@{userInfo.username}
Joined {userInfo.signUpDate}
diff --git a/src/pages/userprofile/editUser/EditPopup.jsx b/src/pages/userprofile/editUser/EditPopup.jsx
index a27530a..54cbe91 100644
--- a/src/pages/userprofile/editUser/EditPopup.jsx
+++ b/src/pages/userprofile/editUser/EditPopup.jsx
@@ -1,7 +1,8 @@
import React, { useEffect, useState } from "react";
-import { auth, db } from "../../../firebase/firebaseConfig";
+import { auth, db, storage } from "../../../lib/firebaseConfig";
import { doc, getDoc, updateDoc, collection, query, where, getDocs, writeBatch } from "firebase/firestore";
import { toast } from 'react-hot-toast';
+import { ref, uploadBytes, getDownloadURL } from "firebase/storage";
import './EditPopup.css';
@@ -12,9 +13,12 @@ function EditPopup({ onClose, onSubmit }) {
email: ""
});
+ const [imageFile, setImageFile] = useState(null);
+
const uploadImage = (e) => {
const file = e.target.files[0];
if (file && file.type.includes('image')) {
+ setImageFile(file);
const fileReader = new FileReader();
fileReader.readAsDataURL(file);
fileReader.onload = (fileReaderEvent) => {
@@ -34,8 +38,16 @@ function EditPopup({ onClose, onSubmit }) {
const userDocRef = doc(db, 'Users', user.uid);
try {
+ let profilePicUrl = formData.image;
+
+ if (imageFile) {
+ const storageRef = ref(storage, `profilePics/${user.uid}/${imageFile.name}`);
+ await uploadBytes(storageRef, imageFile);
+ profilePicUrl = await getDownloadURL(storageRef);
+ }
+
await updateDoc(userDocRef, {
- profilePic: formData.image,
+ profilePic: profilePicUrl,
username: formData.username,
email: formData.email
});
@@ -101,7 +113,7 @@ function EditPopup({ onClose, onSubmit }) {
name="image"
onChange={uploadImage} />
-
+
diff --git a/src/pages/userprofile/userReviews/UserReviews.jsx b/src/pages/userprofile/userReviews/UserReviews.jsx
index b87d152..6445be4 100644
--- a/src/pages/userprofile/userReviews/UserReviews.jsx
+++ b/src/pages/userprofile/userReviews/UserReviews.jsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { doc, getDoc } from 'firebase/firestore';
-import { db } from '../../../firebase/firebaseConfig';
+import { db } from '../../../lib/firebaseConfig';
import { FaStar } from 'react-icons/fa';
import './UserReviews.css';
diff --git a/src/pages/viewproduct/ViewProduct.jsx b/src/pages/viewproduct/ViewProduct.jsx
index cb690c2..644ad34 100644
--- a/src/pages/viewproduct/ViewProduct.jsx
+++ b/src/pages/viewproduct/ViewProduct.jsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { doc, getDoc, addDoc, collection, deleteDoc, query, where, getDocs, updateDoc } from 'firebase/firestore';
-import { db } from '../../firebase/firebaseConfig';
+import { db } from '../../lib/firebaseConfig';
import { useAuth } from '../../Auth';
import { FaRegHeart, FaHeart, FaStar, FaStarHalf } from "react-icons/fa";
import { FaEllipsisVertical } from 'react-icons/fa6';
diff --git a/src/pages/viewproduct/offerPopup/offerPopup.jsx b/src/pages/viewproduct/offerPopup/offerPopup.jsx
index 7aee2c0..9c675c4 100644
--- a/src/pages/viewproduct/offerPopup/offerPopup.jsx
+++ b/src/pages/viewproduct/offerPopup/offerPopup.jsx
@@ -1,5 +1,5 @@
import React, { useState } from "react";
-import { auth, db } from "../../../firebase/firebaseConfig";
+import { auth, db } from "../../../lib/firebaseConfig";
import { doc, addDoc, collection } from "firebase/firestore";
import { toast } from 'react-hot-toast';
diff --git a/src/pages/viewproduct/viewOffers/viewOffers.jsx b/src/pages/viewproduct/viewOffers/viewOffers.jsx
index 7a76fb9..43dbeaa 100644
--- a/src/pages/viewproduct/viewOffers/viewOffers.jsx
+++ b/src/pages/viewproduct/viewOffers/viewOffers.jsx
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { doc, updateDoc, collection, deleteDoc, addDoc, getDoc } from 'firebase/firestore';
-import { db } from '../../../firebase/firebaseConfig';
+import { db } from '../../../lib/firebaseConfig';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-hot-toast';
import { useAuth } from '../../../Auth';