import { useState } from "react"; import { useFetcher } from "@remix-run/react"; import { AlertCircle, Info, Trash } from "lucide-react"; import { cn } from "~/lib/utils"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog"; import { Button } from "../ui"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "../ui/alert-dialog"; interface LogTextCollapseProps { text?: string; error?: string; logData: any; id: string; episodeUUID?: string; } export function LogTextCollapse({ episodeUUID, text, error, id, logData, }: LogTextCollapseProps) { const [dialogOpen, setDialogOpen] = useState(false); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const deleteFetcher = useFetcher(); const handleDelete = () => { if (!episodeUUID) { console.error("No episodeUuid found in log data"); return; } deleteFetcher.submit( { id }, { method: "DELETE", action: "/api/v1/ingestion_queue/delete", encType: "application/json", }, ); setDeleteDialogOpen(false); }; // Show collapse if text is long (by word count) const COLLAPSE_WORD_LIMIT = 30; if (!text) { return (
{displayText}
{isLong && ( <> > )}