Skip to content

Commit

Permalink
fix: user profile values
Browse files Browse the repository at this point in the history
Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
bhavanakarwade committed Dec 4, 2024
1 parent 069c2aa commit 5e252e0
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions src/components/Profile/DisplayUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,16 @@ const DisplayUser = () => {
const [userObj, setUserObj] = useState(null)

let timer:any= null
// const getUserDetails = async () => {
// const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE)
// const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES)
// const parsedUser = userProfile ? JSON.parse(userProfile) : null

// if (parsedUser) {
// parsedUser.roles = orgRoles;
// setUserObj(parsedUser);
// }
// }

const getUserDetails = async () => {
try {
const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE);
const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES);
const parsedUser = userProfile ? JSON.parse(userProfile) : null;
const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE)
const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES)
const parsedUser = userProfile ? JSON.parse(userProfile) : null

if (parsedUser) {
parsedUser.roles = orgRoles || []; // Default to an empty array if orgRoles is null
setUserObj(parsedUser);
} else {
console.warn("User profile is not available in local storage.");
}
} catch (error) {
console.error("Error fetching user details:", error);
if (parsedUser) {
parsedUser.roles = orgRoles;
setUserObj(parsedUser);
}
};
}

useEffect(() => {
const fetchData = async () => {
Expand Down

0 comments on commit 5e252e0

Please sign in to comment.