From 44b8281c0dfcdfb02f36c1173d47230f63c5dc64 Mon Sep 17 00:00:00 2001 From: Jonna Date: Sun, 28 Sep 2025 10:11:26 +0200 Subject: [PATCH 1/3] probably fixed a navigation bug when updating a profile page. Will test on monday --- src/pages/profile/ProfilePage.jsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index fa2459e..39e0c3c 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -94,14 +94,6 @@ const ProfilePage = () => { setTempCurrentUser((prev) => ({ ...prev, [field]: value })); }; - // const toggleEdit = async () => { - // if (isEditing) { - // try { - // tempCurrentUser.id = pathParamId || user.id; - - // const { cohort, ...userWithoutCohort } = tempCurrentUser; - // await onPatchProfile(userWithoutCohort); - // When edit button gets toggled on/off const toggleEdit = () => { if (isEditing) { @@ -109,14 +101,14 @@ const ProfilePage = () => { tempCurrentUser.id = pathParamId || user.id; const { cohort, ...tempCurrentUserWithoutCohort } = tempCurrentUser; - // if the password field is empty then patch without changing password, else patch with new password. + // If password is empty, we don't want to send it in the body. if (tempCurrentUser.password === '') { - onCreateProfile(tempCurrentUserWithoutCohort); - } else { - onPatchProfile(tempCurrentUserWithoutCohort); + delete tempCurrentUserWithoutCohort.password; } + onPatchProfile(tempCurrentUserWithoutCohort); + tempCurrentUser.password = ''; const { password, ...userWithoutPassword } = tempCurrentUser; From 273b0b1208858400917ea43a2030ccabc905fd20 Mon Sep 17 00:00:00 2001 From: Jonnashell <35744008+Jonnashell@users.noreply.github.com> Date: Mon, 29 Sep 2025 08:39:50 +0200 Subject: [PATCH 2/3] Clicking profile icon top right corner bug fix --- src/components/header/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/header/index.js b/src/components/header/index.js index 49a3aa6..1ff194b 100644 --- a/src/components/header/index.js +++ b/src/components/header/index.js @@ -15,22 +15,29 @@ const Header = () => { const contextValues = useContext(AuthContext); const storedUser = contextValues.user; const name = storedUser ? `${storedUser.firstName} ${storedUser.lastName}` : 'Unknown User'; + const menuRef = useRef(null); + const buttonRef = useRef(null); + const onClickProfileIcon = () => { - setIsMenuVisible(!isMenuVisible); + setIsMenuVisible((v) => !v); }; useEffect(() => { if (!isMenuVisible) return; const handleClickOutside = (event) => { - if (menuRef.current && !menuRef.current.contains(event.target)) { + if ( + menuRef.current && + !menuRef.current.contains(event.target) && + buttonRef.current && + !buttonRef.current.contains(event.target) + ) { setIsMenuVisible(false); } }; document.addEventListener('mousedown', handleClickOutside); - return () => { document.removeEventListener('mousedown', handleClickOutside); }; @@ -45,7 +52,7 @@ const Header = () => { {user?.firstName && token && ( -
+
)} From 805a0dde9820185e6ae9bdb19d7d3a87286662c6 Mon Sep 17 00:00:00 2001 From: reduan-azouaghe Date: Mon, 29 Sep 2025 09:06:54 +0200 Subject: [PATCH 3/3] lint, remove unused variable --- src/pages/profile/ProfilePage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index 39e0c3c..202d3fa 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -21,7 +21,7 @@ import { const ProfilePage = () => { const { id: pathParamId } = useParams(); - const { user, setUser, onPatchProfile, onCreateProfile } = useAuth(); + const { user, setUser, onPatchProfile } = useAuth(); const [isLoading, setIsLoading] = useState(null); const location = useLocation(); const isEditing = location.pathname.endsWith('edit');