1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/components/UserAvatar.tsx

33 lines
889 B
TypeScript
Raw Normal View History

2023-06-04 02:34:40 -04:00
import React, { FC } from 'react';
import type { UserDto } from '@jellyfin/sdk/lib/generated-client/models/user-dto';
import Avatar from '@mui/material/Avatar';
import { useTheme } from '@mui/material/styles';
import { useApi } from 'hooks/useApi';
interface UserAvatarProps {
user?: UserDto
}
const UserAvatar: FC<UserAvatarProps> = ({ user }) => {
2023-06-04 02:34:40 -04:00
const { api } = useApi();
const theme = useTheme();
return user ? (
<Avatar
alt={user.Name ?? undefined}
src={
api && user.Id && user.PrimaryImageTag ?
`${api.basePath}/Users/${user.Id}/Images/Primary?tag=${user.PrimaryImageTag}` :
undefined
}
sx={{
bgcolor: theme.palette.primary.dark,
color: 'inherit'
}}
/>
) : null;
};
export default UserAvatar;