Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handled conditions for undefined value for user roles #833

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/Profile/DisplayProfileImg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
11 changes: 7 additions & 4 deletions src/components/Profile/DisplayUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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']}
</p>
<p className="text-sm text-gray-900 dark:text-white mb-1" role="none">
{userObj['email']}
{userObj?.['email']}
</p>
<p
className="text-base font-medium text-gray-900 truncate dark:text-gray-300"
Expand Down
Loading