2022-08-15 19:52:01 +00:00
|
|
|
import { CAL_URL } from "@calcom/lib/constants";
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { AvatarGroupProps } from "@calcom/ui";
|
|
|
|
import { AvatarGroup } from "@calcom/ui";
|
2022-08-15 19:52:01 +00:00
|
|
|
|
|
|
|
export const UserAvatars = ({
|
|
|
|
profile,
|
|
|
|
users,
|
|
|
|
...props
|
|
|
|
}: {
|
2022-11-25 12:12:16 +00:00
|
|
|
profile: { image: string | null; name?: string | null; username?: string | null };
|
2022-08-15 19:52:01 +00:00
|
|
|
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
|
|
|
|
items={
|
|
|
|
[
|
2022-11-25 12:12:16 +00:00
|
|
|
{
|
|
|
|
image: profile.image,
|
|
|
|
alt: profile.name,
|
|
|
|
title: profile.name,
|
|
|
|
href: profile.username ? `${CAL_URL}/${profile.username}` : undefined,
|
|
|
|
},
|
2022-08-15 19:52:01 +00:00
|
|
|
...(showMembers
|
|
|
|
? users.map((user) => ({
|
|
|
|
title: user.name,
|
|
|
|
image: `${CAL_URL}/${user.username}/avatar.png`,
|
|
|
|
alt: user.name || undefined,
|
2022-11-25 12:12:16 +00:00
|
|
|
href: user.username ? `${CAL_URL}/${user.username}` : undefined,
|
2022-08-15 19:52:01 +00:00
|
|
|
}))
|
|
|
|
: []),
|
2022-11-25 12:12:16 +00:00
|
|
|
].filter((item) => !!item.image) as {
|
|
|
|
image: string;
|
|
|
|
alt?: string;
|
|
|
|
title?: string;
|
|
|
|
href?: string;
|
|
|
|
}[]
|
2022-08-15 19:52:01 +00:00
|
|
|
}
|
2023-01-21 22:09:32 +00:00
|
|
|
size="sm"
|
2022-08-15 19:52:01 +00:00
|
|
|
truncateAfter={props.truncateAfter}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|