feat: add UserProfilePopup to UserAvatar and update CoursesActions to show profile popups for authors

This commit is contained in:
swve 2025-03-29 18:31:17 +01:00
parent 5a2732258f
commit 04c5b845fb
6 changed files with 264 additions and 9 deletions

View file

@ -3,6 +3,7 @@ import { getUriWithOrg } from '@services/config/config'
import { useParams } from 'next/navigation'
import { getUserAvatarMediaDirectory } from '@services/media/media'
import { useLHSession } from '@components/Contexts/LHSessionContext'
import UserProfilePopup from './UserProfilePopup'
type UserAvatarProps = {
width?: number
@ -13,6 +14,8 @@ type UserAvatarProps = {
borderColor?: string
predefined_avatar?: 'ai' | 'empty'
backgroundColor?: 'bg-white' | 'bg-gray-100'
showProfilePopup?: boolean
userId?: string
}
function UserAvatar(props: UserAvatarProps) {
@ -69,7 +72,7 @@ function UserAvatar(props: UserAvatarProps) {
return getUriWithOrg(params.orgslug, '/empty_avatar.png')
}
return (
const avatarImage = (
<img
alt="User Avatar"
width={props.width ?? 50}
@ -88,6 +91,16 @@ function UserAvatar(props: UserAvatarProps) {
`}
/>
)
if (props.showProfilePopup && props.userId) {
return (
<UserProfilePopup userId={props.userId}>
{avatarImage}
</UserProfilePopup>
)
}
return avatarImage
}
export default UserAvatar