2021-09-22 19:52:38 +00:00
|
|
|
import Link from "next/link";
|
|
|
|
|
2022-05-30 07:57:48 +00:00
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
2023-02-14 15:01:34 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-03-12 23:31:55 +00:00
|
|
|
import type { TeamWithMembers } from "@calcom/lib/server/queries/teams";
|
2022-11-23 02:55:25 +00:00
|
|
|
import { Avatar } from "@calcom/ui";
|
2022-03-16 23:36:43 +00:00
|
|
|
|
2023-03-12 23:31:55 +00:00
|
|
|
type TeamType = NonNullable<TeamWithMembers>;
|
2021-12-09 23:51:30 +00:00
|
|
|
type MembersType = TeamType["members"];
|
2023-03-23 12:00:42 +00:00
|
|
|
type MemberType = MembersType[number] & { safeBio: string | null };
|
|
|
|
|
|
|
|
type TeamTypeWithSafeHtml = Omit<TeamType, "members"> & { members: MemberType[] };
|
2021-12-09 23:51:30 +00:00
|
|
|
|
2022-09-29 16:34:01 +00:00
|
|
|
const Member = ({ member, teamName }: { member: MemberType; teamName: string | null }) => {
|
2021-10-12 13:11:33 +00:00
|
|
|
const { t } = useLocale();
|
2021-10-08 11:43:48 +00:00
|
|
|
|
2023-01-25 01:08:10 +00:00
|
|
|
const isBioEmpty = !member.bio || !member.bio.replace("<p><br></p>", "").length;
|
|
|
|
|
2022-09-29 16:34:01 +00:00
|
|
|
return (
|
|
|
|
<Link key={member.id} href={`/${member.username}`}>
|
2023-03-03 23:20:13 +00:00
|
|
|
<div className="sm:min-w-80 sm:max-w-80 dark:bg-darkgray-200 dark:hover:bg-darkgray-300 group flex min-h-full flex-col space-y-2 rounded-md bg-white p-4 hover:cursor-pointer hover:bg-gray-50 ">
|
2022-09-29 16:34:01 +00:00
|
|
|
<Avatar
|
|
|
|
size="md"
|
|
|
|
alt={member.name || ""}
|
|
|
|
imageSrc={WEBAPP_URL + "/" + member.username + "/avatar.png"}
|
|
|
|
/>
|
|
|
|
<section className="line-clamp-4 mt-2 w-full space-y-1">
|
2023-01-12 16:57:43 +00:00
|
|
|
<p className="font-medium text-gray-900 dark:text-white">{member.name}</p>
|
2023-01-25 01:08:10 +00:00
|
|
|
<div className="line-clamp-3 overflow-ellipsis text-sm font-normal text-gray-500 dark:text-white">
|
|
|
|
{!isBioEmpty ? (
|
|
|
|
<>
|
|
|
|
<div
|
2023-01-27 16:03:04 +00:00
|
|
|
className="dark:text-darkgray-600 text-sm text-gray-500 [&_a]:text-blue-500 [&_a]:underline [&_a]:hover:text-blue-600"
|
2023-03-23 12:00:42 +00:00
|
|
|
dangerouslySetInnerHTML={{ __html: member.safeBio || "" }}
|
2023-01-25 01:08:10 +00:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
t("user_from_team", { user: member.name, team: teamName })
|
|
|
|
)}
|
|
|
|
</div>
|
2022-09-29 16:34:01 +00:00
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-03-23 12:00:42 +00:00
|
|
|
const Members = ({ members, teamName }: { members: MemberType[]; teamName: string | null }) => {
|
2022-09-29 16:34:01 +00:00
|
|
|
if (!members || members.length === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-08-13 19:46:42 +00:00
|
|
|
|
2022-09-29 16:34:01 +00:00
|
|
|
return (
|
|
|
|
<section className="lg:min-w-lg mx-auto flex min-w-full max-w-5xl flex-wrap justify-center gap-x-6 gap-y-6">
|
|
|
|
{members.map((member) => {
|
|
|
|
return member.username !== null && <Member key={member.id} member={member} teamName={teamName} />;
|
|
|
|
})}
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-03-23 12:00:42 +00:00
|
|
|
const Team = ({ team }: { team: TeamTypeWithSafeHtml }) => {
|
2021-08-13 19:46:42 +00:00
|
|
|
return (
|
2021-09-14 08:45:28 +00:00
|
|
|
<div>
|
2022-09-29 16:34:01 +00:00
|
|
|
<Members members={team.members} teamName={team.name} />
|
2021-09-14 08:45:28 +00:00
|
|
|
</div>
|
2021-08-13 19:46:42 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Team;
|