import { CircularProgress } from '@mui/material'; import { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Workspace } from '@/application/types'; import MoreActions from '@/components/app/workspaces/MoreActions'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { DropdownMenuItem, DropdownMenuItemTick } from '@/components/ui/dropdown-menu'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; export function WorkspaceItem({ workspace, showActions = true, onChange, currentWorkspaceId, changeLoading, onUpdate, onDelete, onLeave, }: { showActions?: boolean; workspace: Workspace; onChange: (id: string) => void; currentWorkspaceId?: string; changeLoading?: string; onUpdate?: (workspace: Workspace) => void; onDelete?: (workspace: Workspace) => void; onLeave?: (workspace: Workspace) => void; }) { const { t } = useTranslation(); const [hovered, setHovered] = useState(false); const renderActions = useMemo(() => { if (changeLoading === workspace.id) return ; if (!showActions) { if (currentWorkspaceId === workspace.id) { return ; } return null; } return (
{currentWorkspaceId === workspace.id && ( )}
onUpdate?.(workspace)} onDelete={() => onDelete?.(workspace)} onLeave={() => onLeave?.(workspace)} />
); }, [changeLoading, currentWorkspaceId, hovered, onDelete, onLeave, onUpdate, showActions, workspace]); return ( { if (workspace.id === currentWorkspaceId) return; void onChange(workspace.id); }} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} > {workspace.name}
{workspace.name}

{workspace.name}

{t('invitation.membersCount', { count: workspace.memberCount || 0 })}
{renderActions}
); }