"use client"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "ui/avatar"; import { useTranslations } from "next-intl"; import { format } from "date-fns"; import { cn } from "lib/utils"; import { ShareableActions, type Visibility } from "./shareable-actions"; import { WorkflowSummary } from "app-types/workflow"; import { AgentSummary } from "app-types/agent"; import { MCPServerInfo } from "app-types/mcp"; import { MCPIcon } from "ui/mcp-icon"; import Link from "next/link"; export interface ShareableIcon { value?: string; style?: { backgroundColor?: string; }; } interface ShareableCardProps { type: "agent" | "workflow" | "mcp"; item: AgentSummary | WorkflowSummary | MCPServerInfo; isOwner?: boolean; href: string; onBookmarkToggle?: (itemId: string, isBookmarked: boolean) => void; onVisibilityChange?: (itemId: string, visibility: Visibility) => void; onDelete?: (itemId: string) => void; isVisibilityChangeLoading?: boolean; isBookmarkToggleLoading?: boolean; isDeleteLoading?: boolean; actionsDisabled?: boolean; } export function ShareableCard({ type, item, isOwner = true, href, onBookmarkToggle, onVisibilityChange, onDelete, isBookmarkToggleLoading, isVisibilityChangeLoading, isDeleteLoading, actionsDisabled, }: ShareableCardProps) { const t = useTranslations(); const isPublished = (item as WorkflowSummary).isPublished; const isBookmarked = type === "mcp" ? undefined : (item as AgentSummary).isBookmarked; return (
{type === "mcp" ? ( ) : ( )}
{item.name}
{type === "workflow" && !isPublished && ( {t("Workflow.draft")} )}
{item.description}
e.stopPropagation()}> onVisibilityChange(item.id, visibility) : undefined } onBookmarkToggle={ onBookmarkToggle ? (isBookmarked) => onBookmarkToggle(item.id, isBookmarked) : undefined } onDelete={onDelete ? () => onDelete(item.id) : undefined} isBookmarkToggleLoading={isBookmarkToggleLoading} isVisibilityChangeLoading={isVisibilityChangeLoading} isDeleteLoading={isDeleteLoading} disabled={actionsDisabled} />
{!isOwner && item.userName && (
{item.userName[0]?.toUpperCase()} {item.userName}
)}
); }