From a7d39bd4acc128a61792d9aa7ebd211e3eecb451 Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Wed, 11 Dec 2024 17:23:14 +0530 Subject: [PATCH] fix: added optional chaining operator --- src/components/Profile/DisplayUser.tsx | 1 - src/components/User/UserDashBoard.tsx | 2 +- src/components/organization/OrgDropDown.tsx | 2 +- src/components/organization/OrganizationsList.tsx | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/Profile/DisplayUser.tsx b/src/components/Profile/DisplayUser.tsx index c8bad7d3a..1ac4e97c9 100644 --- a/src/components/Profile/DisplayUser.tsx +++ b/src/components/Profile/DisplayUser.tsx @@ -11,7 +11,6 @@ const DisplayUser = () => { let timer:any= null const getUserDetails = async () => { const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) - console.log("🚀 ~ getUserDetails ~ userProfile11111111111:", userProfile) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) userProfile.roles = orgRoles; setUserObj(userProfile); diff --git a/src/components/User/UserDashBoard.tsx b/src/components/User/UserDashBoard.tsx index ee3b53c97..8d7532092 100644 --- a/src/components/User/UserDashBoard.tsx +++ b/src/components/User/UserDashBoard.tsx @@ -352,7 +352,7 @@ const UserDashBoard = () => { const setOrgRoleDetails = async (org: Organisation) => { await setToLocalStorage(storageKeys.ORG_ID, org.id.toString()); - const roles: string[] = org?.userOrgRoles.map((role) => role.orgRole.name); + const roles: string[] = org?.userOrgRoles?.map((role) => role.orgRole.name); await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString()); diff --git a/src/components/organization/OrgDropDown.tsx b/src/components/organization/OrgDropDown.tsx index 3779cd715..89fea63b3 100644 --- a/src/components/organization/OrgDropDown.tsx +++ b/src/components/organization/OrgDropDown.tsx @@ -82,7 +82,7 @@ const OrgDropDown = () => { } else if (organizations?.[0]) { activeOrgDetails = organizations?.[0]; const roles: string[] = activeOrgDetails?.userOrgRoles?.map( - (role: { orgRole: { name: string } }) => role.orgRole.name, + (role: { orgRole: { name: string } }) => role?.orgRole?.name, ); const { id, name, description, logoUrl } = organizations[0] || {}; const orgInfo = { diff --git a/src/components/organization/OrganizationsList.tsx b/src/components/organization/OrganizationsList.tsx index 810498810..f9252341e 100644 --- a/src/components/organization/OrganizationsList.tsx +++ b/src/components/organization/OrganizationsList.tsx @@ -116,7 +116,7 @@ const OrganizationsList = () => { await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString()); const roles: string[] = activeOrg?.userOrgRoles.map( - (role) => role.orgRole.name, + (role) => role?.orgRole?.name, ); const { id, name, description, logoUrl } = activeOrg || {}; const orgInfo = {