From 8d7a55c5f85429f0722f8bc291ff2a5bd4ca8514 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Tue, 24 Feb 2026 17:29:24 +0100 Subject: [PATCH] Fix update --- src/pages/Profile/ProfilePage.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/pages/Profile/ProfilePage.tsx b/src/pages/Profile/ProfilePage.tsx index f0037f9..8e613d0 100644 --- a/src/pages/Profile/ProfilePage.tsx +++ b/src/pages/Profile/ProfilePage.tsx @@ -4,8 +4,8 @@ import {AuthContext} from "../../contexts/auth/AuthContext"; import formatDate from "../../utils/date/formatDate"; import Task from "../../components/Task/Task"; import SettingsModal from "./components/SettingsModal/SettingsModal"; -import { useParams } from "react-router"; -import { useNavigate } from "react-router"; +import {useParams} from "react-router"; +import {useNavigate} from "react-router"; import getUserById from "../../utils/users/getUserById.js"; import ManageMember from "./components/manageMember/ManageMember.jsx"; @@ -35,21 +35,20 @@ interface AuthContextType { update: () => void; } - function ProfilePage() { const navigate = useNavigate(); - const { id } = useParams(); - const { user, update } = useContext(AuthContext) as AuthContextType; + const {id} = useParams(); + const {user, update} = useContext(AuthContext) as AuthContextType; const [profileUser, setProfileUser] = useState(null); const isOwnProfile = !id || user.id.toString() === id; useEffect(() => { - update(); + (async () => { - if(!isOwnProfile) { + if (!isOwnProfile) { console.log(id); const res = await getUserById(id); @@ -64,9 +63,12 @@ function ProfilePage() { } setProfileUser(res.data); - } else setProfileUser(user) - }) () - }, []); + } else { + update(); + setProfileUser(user) + } + })() + }, [user]); return (
@@ -86,7 +88,7 @@ function ProfilePage() { {profileUser?.name} {profileUser?.lastname} {(user?.isAdmin && profileUser && !isOwnProfile) && ( - + )}
@@ -113,7 +115,7 @@ function ProfilePage() { {isOwnProfile && (
- +
)}