2022-08-15 19:52:01 +00:00
|
|
|
import { CAL_URL } from "@calcom/lib/constants";
|
|
|
|
|
|
|
|
import AvatarGroup, { AvatarGroupProps } from "@components/ui/AvatarGroup";
|
|
|
|
|
|
|
|
export const UserAvatars = ({
|
|
|
|
profile,
|
|
|
|
users,
|
|
|
|
...props
|
|
|
|
}: {
|
|
|
|
profile: { image: string | null; name?: string | null };
|
|
|
|
showMembers: boolean;
|
|
|
|
users: { username: string | null; name?: string | null }[];
|
|
|
|
} & Pick<AvatarGroupProps, "size" | "truncateAfter">) => {
|
|
|
|
const showMembers = !users.find((user) => user.name === profile.name) && props.showMembers;
|
|
|
|
return (
|
|
|
|
<AvatarGroup
|
2022-09-05 10:27:40 +00:00
|
|
|
border="border-2 dark:border-darkgray-100 border-white"
|
2022-08-15 19:52:01 +00:00
|
|
|
items={
|
|
|
|
[
|
|
|
|
{ image: profile.image, alt: profile.name, title: profile.name },
|
|
|
|
...(showMembers
|
|
|
|
? users.map((user) => ({
|
|
|
|
title: user.name,
|
|
|
|
image: `${CAL_URL}/${user.username}/avatar.png`,
|
|
|
|
alt: user.name || undefined,
|
|
|
|
}))
|
|
|
|
: []),
|
|
|
|
].filter((item) => !!item.image) as { image: string; alt?: string; title?: string }[]
|
|
|
|
}
|
|
|
|
size={props.size}
|
|
|
|
truncateAfter={props.truncateAfter}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|