import { cn } from "~/lib/utils"; import { Badge, BadgeColor } from "../ui/badge"; import { type LogItem } from "~/hooks/use-logs"; import { getIconForAuthorise } from "../icon-utils"; import { useNavigate, useParams } from "@remix-run/react"; import { getStatusColor, getStatusValue } from "./utils"; import { File, MessageSquare } from "lucide-react"; interface LogTextCollapseProps { text?: string; error?: string; logData: any; log: LogItem; id: string; reset?: () => void; } export function LogTextCollapse({ text, log }: LogTextCollapseProps) { const { logId } = useParams(); const navigate = useNavigate(); // Show collapse if text is long (by word count) const COLLAPSE_WORD_LIMIT = 30; if (!text) { return (
No log details.
); } // Split by words for word count const words = text.split(/\s+/); const isLong = words.length > COLLAPSE_WORD_LIMIT; let displayText: string; if (isLong) { displayText = words.slice(0, COLLAPSE_WORD_LIMIT).join(" ") + " ..."; } else { displayText = text; } const showStatus = (log: LogItem) => { if (log.status === "COMPLETED") { return false; } return true; }; const getIngestType = (log: LogItem) => { const type = log.type ?? log.data.type ?? "CONVERSATION"; return type === "CONVERSATION" ? ( ) : ( ); }; return (
{ navigate(`/home/inbox/${log.id}`); }} >
{text.replace(/<[^>]+>/g, "")}
{showStatus(log) && (
{getStatusValue(log.status)}
)}
{getIconForAuthorise(log.source.toLowerCase(), 12, undefined)} {log.source.toLowerCase()}
{getIngestType(log)}
); }