Skip to content

Commit

Permalink
refactor ZUIPersonAvatar to use ZUIAvatar
Browse files Browse the repository at this point in the history
  • Loading branch information
rebecarubio committed Sep 7, 2023
1 parent ba9e758 commit 68f9db2
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions src/zui/ZUIPersonAvatar/index.tsx
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;

0 comments on commit 68f9db2

Please sign in to comment.