8000 fix: worked on the user profile image and dropdown display by nishad-ayanworks · Pull Request #185 · credebl/studio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: worked on the user profile image and dropdown display #185

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

Merged
merged 1 commit into from
Aug 31, 2023
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
11 changes: 4 additions & 7 deletions src/app/NavBarSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { asset } from '../lib/data.js';
import ColorModeSwitcher from '../components/ColorModeSwitcher.astro';
import OrgDropDwon from '../components/organization/OrgDropDown';
import DisplayUser from '../components/Profile/DisplayUser';
import DisplayProfileImg from '../components/Profile/DisplayProfileImg';
import { pathRoutes } from '../config/pathRoutes.js';
import SignOutButton from '../components/SignOutButton/index';
import AgentHealth from '../commonComponents/AgentHealth';
Expand Down Expand Up @@ -652,20 +653,16 @@ throw new Error('Function not implemented.');
aria-expanded="false"
data-dropdown-toggle="dropdown-2"
>
<span class="sr-only">Open user menu</span>
<img
class="w-8 h-8 rounded-full"
src="https://flowbite.com/docs/images/people/profile-picture-5.jpg"
alt="user photo"
/>
<span class="sr-only">Open user menu</span>
<DisplayProfileImg client:load/>
</button>
</div>
<!-- Dropdown menu -->
<div
class="z-50 hidden my-4 text-base list-none bg-white divide-y divide-gray-100 rounded shadow dark:bg-gray-700 dark:divide-gray-600"
id="dropdown-2"
>
<DisplayUser client:visible />
<DisplayUser client:load />
<ul class="py-1" role="none">
<!--li>
<a
Expand Down
40 changes: 40 additions & 0 deletions src/components/Profile/DisplayProfileImg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useEffect, useState } from "react";

import CustomAvatar from '../Avatar'
import type { UserProfile } from "./interfaces";
import { getFromLocalStorage } from "../../api/Auth";
import { storageKeys } from "../../config/CommonConstant";

const DisplayProfileImg = () => {

const [userObj, setUserObj] = useState<UserProfile | null>(null)

const getUserDetails = async () => {
const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE)
const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES)
const parsedUser = JSON.parse(userProfile)
parsedUser.roles = orgRoles

setUserObj(parsedUser)
}

useEffect(() => {
getUserDetails()
}, [])


return (
<>
{(userObj?.profileImg) ?
<CustomAvatar
className="rounded-full w-8 h-8"
src={userObj?.profileImg}
/> :
<CustomAvatar
className="rounded-full w-8 h-8"
name={userObj?.firstName ? userObj?.firstName : userObj?.email} />}
</>
)
}

export default DisplayProfileImg
0