From 9419ddfd9e7366fff038d54e624c48c2fe17596d Mon Sep 17 00:00:00 2001 From: Oitash Date: Mon, 4 Nov 2024 02:02:38 +0530 Subject: [PATCH] :hammer:Working.... --- server/controllers/Profile.js | 4 +- server/routes/Profile.js | 2 +- src/App.js | 2 +- src/components/core/Dashboard/MyProfile.jsx | 9 ++-- .../Settings/ChangeProfilePicture.jsx | 33 ++++++------ .../core/Dashboard/Settings/EditProfile.jsx | 54 +++++++++++++------ .../Dashboard/Settings/UpdatePassword.jsx | 34 ++++++++---- src/components/core/Dashboard/Sidebar.jsx | 2 +- src/components/core/Dashboard/SidebarLink.jsx | 5 +- src/pages/ForgotPassword.jsx | 5 +- src/pages/UpdatePassword.jsx | 18 ++++--- src/services/operations/SettingsAPI.js | 24 ++++++--- 12 files changed, 124 insertions(+), 68 deletions(-) diff --git a/server/controllers/Profile.js b/server/controllers/Profile.js index 05e43c4..edc8b63 100644 --- a/server/controllers/Profile.js +++ b/server/controllers/Profile.js @@ -11,7 +11,7 @@ exports.updateProfile = async(req, res) => { try{ //get the data - const {dateofBirth = "", about = "", contactNumber, gender} = req.body + const {dateOfBirth = "", about = "", contactNumber, gender} = req.body //get the userID const id = req.user.id @@ -39,7 +39,7 @@ exports.updateProfile = async(req, res) => { //Another way to update the values in database..i.e..by save //When object already present(here profileDetails) then use save //First one was by create...here no object was created - profileDetails.dateOfBirth = dateofBirth + profileDetails.dateOfBirth = dateOfBirth profileDetails.about = about profileDetails.gender = gender profileDetails.contactNumber = contactNumber diff --git a/server/routes/Profile.js b/server/routes/Profile.js index a677436..55952fd 100644 --- a/server/routes/Profile.js +++ b/server/routes/Profile.js @@ -13,7 +13,7 @@ const { // ******************************************************************************************************** // Profile routes // ******************************************************************************************************** -// Delet User Account +// Delete User Account router.delete("/deleteProfile", auth, deleteAccount) router.put("/updateProfile", auth, updateProfile) router.get("/getUserDetails", auth, getAllUserDetails) diff --git a/src/App.js b/src/App.js index 509045e..e915a87 100644 --- a/src/App.js +++ b/src/App.js @@ -113,7 +113,7 @@ function App() { }/> { - //If this validation is not added, then instructor can also open ebrolled-courses and cart page which is logically wrong + //If this validation is not added, then instructor can also open enrolled-courses and cart page which is logically wrong //That's why this validation is added //Always add ? to ensure whether accountType is present or not user?.accountType === ACCOUNT_TYPE.STUDENT && ( diff --git a/src/components/core/Dashboard/MyProfile.jsx b/src/components/core/Dashboard/MyProfile.jsx index 638397c..673feed 100644 --- a/src/components/core/Dashboard/MyProfile.jsx +++ b/src/components/core/Dashboard/MyProfile.jsx @@ -10,7 +10,8 @@ const MyProfile = () => { const {user} = useSelector((state) => state.profile) const navigate = useNavigate() - + console.log("User -> ", user) + return (

@@ -51,8 +52,8 @@ const MyProfile = () => {

About

{ - navigate("/dashboard/settings") + onClick={() => { + navigate("/dashboard/settings") }} > @@ -76,7 +77,7 @@ const MyProfile = () => {

{ + onClick={() => { navigate("/dashboard/settings") }} > diff --git a/src/components/core/Dashboard/Settings/ChangeProfilePicture.jsx b/src/components/core/Dashboard/Settings/ChangeProfilePicture.jsx index af3f80d..c8c0609 100644 --- a/src/components/core/Dashboard/Settings/ChangeProfilePicture.jsx +++ b/src/components/core/Dashboard/Settings/ChangeProfilePicture.jsx @@ -17,15 +17,15 @@ const ChangeProfilePicture = () => { const fileInputRef = useRef(null) const handleClick = () => { - fileInputRef.current.click() + fileInputRef.current.click() } const handleFileChange = (e) => { const file = e.target.files[0] // console.log(file) if (file) { - setImageFile(file) - previewFile(file) + setImageFile(file) + previewFile(file) } } @@ -34,27 +34,29 @@ const ChangeProfilePicture = () => { reader.readAsDataURL(file) reader.onloadend = () => { setPreviewSource(reader.result) - } + } } const handleFileUpload = () => { try { - console.log("uploading...") - setLoading(true) - const formData = new FormData() - formData.append("displayPicture", imageFile) - // console.log("formdata", formData) - dispatch(updateDisplayPicture(token, formData)).then(() => { + console.log("uploading...") + setLoading(true) + const formData = new FormData() + formData.append("displayPicture", imageFile) + console.log("formdata", formData) + + dispatch(updateDisplayPicture(token, formData)).then(() => { setLoading(false) - }) - } catch (error) { - console.log("ERROR MESSAGE - ", error.message) + }) + } + catch (error) { + console.log("ERROR MESSAGE - ", error.message) } } useEffect(() => { if (imageFile) { - previewFile(imageFile) + previewFile(imageFile) } }, [imageFile]) @@ -83,9 +85,10 @@ const ChangeProfilePicture = () => { > Select + {!loading && ( diff --git a/src/components/core/Dashboard/Settings/EditProfile.jsx b/src/components/core/Dashboard/Settings/EditProfile.jsx index 5255265..cec1200 100644 --- a/src/components/core/Dashboard/Settings/EditProfile.jsx +++ b/src/components/core/Dashboard/Settings/EditProfile.jsx @@ -21,11 +21,12 @@ const EditProfile = () => { } = useForm() const submitProfileForm = async (data) => { - // console.log("Form Data - ", data) + console.log("Form Data while submitting the form-> ", data) try { - dispatch(updateProfile(token, data)) - } catch (error) { - console.log("ERROR MESSAGE - ", error.message) + dispatch(updateProfile(token, data)) + } + catch (error) { + console.log("ERROR MESSAGE - ", error.message) } } @@ -38,7 +39,7 @@ const EditProfile = () => {

-
+
-