/** * @file dashboard/card/CardAvatars.tsx * @description Client component rendering team avatars and creator badge for a card. */ "use client"; import { Crown } from "lucide-react"; import { Task } from "@/types/task"; import { getInitials } from "@/utils/user"; /** * Properties for the UserAvatar component. * * @interface UserAvatarProps * @property {Task["creator"]} user - The user object to render. * @property {string} title - The role description (e.g., "Creator" or "Assignee"). * @property {boolean} [isCreator] - Optional flag indicating if the user is the creator. */ interface UserAvatarProps { user: Task["creator"]; title: string; isCreator?: boolean; } /** * Renders a single user avatar circle with optional crown badge. * * @param {UserAvatarProps} props - The component props. * @returns {JSX.Element} The rendered user avatar component. */ function UserAvatar({ user, title, isCreator }: UserAvatarProps) { const fullName = `${user.firstName} ${user.lastName}`; const initials = getInitials(user.firstName, user.lastName); const bgColor = user.color; return (
{initials}
{isCreator && ( )}
); } /** * Properties for the CardAvatars component. * * @interface CardAvatarsProps * @property {Task["creator"]} creator - The creator user object. * @property {Task["assignees"]} assignees - The list of assigned user objects. */ interface CardAvatarsProps { creator: Task["creator"]; assignees: Task["assignees"]; } /** * Renders overlapping avatar indicators for task assignees and a dedicated, crowned badge for the task creator. * * @param {CardAvatarsProps} props - The component props. * @returns {JSX.Element | null} The rendered card avatars container or null if no users are available. */ export default function CardAvatars({ creator, assignees = [], }: CardAvatarsProps) { const filteredAssignees = (assignees || []).filter( (assignee) => assignee.id !== creator?.id, ); if (!creator && filteredAssignees.length === 0) return null; return (
{filteredAssignees.map((assignee) => ( ))} {creator && ( )}
); }