From a757473bfe280c21088f3853997e9df3756494ea Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Wed, 4 Dec 2024 16:13:06 +0530 Subject: [PATCH] fix: solved react minified error Signed-off-by: bhavanakarwade --- src/components/Profile/DisplayProfileImg.tsx | 7 +++++-- src/components/Profile/DisplayUser.tsx | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/Profile/DisplayProfileImg.tsx b/src/components/Profile/DisplayProfileImg.tsx index bebfd4d53..36e80fef8 100644 --- a/src/components/Profile/DisplayProfileImg.tsx +++ b/src/components/Profile/DisplayProfileImg.tsx @@ -11,8 +11,11 @@ const DisplayProfileImg = () => { const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) const parsedUser = userProfile ? JSON.parse(userProfile) : null; - parsedUser.roles = orgRoles - setUserObj(parsedUser) + + if (parsedUser) { + parsedUser.roles = orgRoles; + setUserObj(parsedUser); + } } useEffect(() => { diff --git a/src/components/Profile/DisplayUser.tsx b/src/components/Profile/DisplayUser.tsx index 83a704006..fbc238f09 100644 --- a/src/components/Profile/DisplayUser.tsx +++ b/src/components/Profile/DisplayUser.tsx @@ -13,8 +13,11 @@ const DisplayUser = () => { const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) const parsedUser = userProfile ? JSON.parse(userProfile) : null - parsedUser.roles = orgRoles - setUserObj(parsedUser) + + if (parsedUser) { + parsedUser.roles = orgRoles; + setUserObj(parsedUser); + } } useEffect(() => { const fetchData = async () => { @@ -39,10 +42,10 @@ const DisplayUser = () => { className="text-xl font-medium text-gray-900 truncate dark:text-gray-300 mb-1" role="none" > - {userObj['firstName']} + {userObj?.['firstName']}

- {userObj['email']} + {userObj?.['email']}