-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor ZUIPersonAvatar to use ZUIAvatar
- Loading branch information
1 parent
ba9e758
commit 68f9db2
Showing
1 changed file
with
13 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,23 @@ | ||
/* eslint-disable react/display-name */ | ||
import { Avatar } from '@mui/material'; | ||
import { forwardRef } from 'react'; | ||
import ZUIAvatar from 'zui/ZUIAvatar'; | ||
|
||
interface ZUIPersonAvatarProps { | ||
orgId: number; | ||
personId: number; | ||
isUserAvatar?: boolean; | ||
size?: 'sm' | 'md' | 'lg'; | ||
} | ||
const SIZES = { | ||
lg: 50, | ||
md: 40, | ||
sm: 30, | ||
}; | ||
|
||
const ZUIPersonAvatar = forwardRef<HTMLDivElement, ZUIPersonAvatarProps>( | ||
( | ||
{ orgId, personId, isUserAvatar = false, size = 'md', ...restProps }, | ||
ref | ||
) => { | ||
return ( | ||
<Avatar | ||
ref={ref} | ||
{...restProps} | ||
src={ | ||
isUserAvatar | ||
? `/api/users/${personId}/avatar` | ||
: `/api/orgs/${orgId}/people/${personId}/avatar` | ||
} | ||
style={{ height: SIZES[size], width: SIZES[size] }} | ||
/> | ||
); | ||
} | ||
); | ||
const ZUIPersonAvatar: React.FC<ZUIPersonAvatarProps> = ({ | ||
orgId, | ||
personId, | ||
size = 'md', | ||
}) => { | ||
return ( | ||
<ZUIAvatar | ||
url={`/api/orgs/${orgId}/people/${personId}/avatar`} | ||
size={size} | ||
/> | ||
); | ||
}; | ||
|
||
export default ZUIPersonAvatar; |