import { useState, useEffect } from "react";
import type { FileDetail as FileDetailType } from "../../lib/api";
import { BodyRenderer } from "./BodyRenderer";
interface FileDetailProps {
file: FileDetailType;
loading: boolean;
onBack: () => void;
onSave: (id: string, name: string, description: string) => void;
onDelete: (id: string) => void;
}
export function FileDetail({
file,
loading,
onBack,
onSave,
onDelete,
}: FileDetailProps) {
const [isEditing, setIsEditing] = useState(false);
const [name, setName] = useState(file.name);
const [description, setDescription] = useState(file.description || "");
const [transcriptExpanded, setTranscriptExpanded] = useState(false);
// Update local state when file changes
useEffect(() => {
setName(file.name);
setDescription(file.description || "");
}, [file.name, file.description]);
const handleSave = () => {
onSave(file.id, name, description);
setIsEditing(false);
};
const handleCancel = () => {
setName(file.name);
setDescription(file.description || "");
setIsEditing(false);
};
if (loading) {
return (
);
}
return (
{/* Header */}
{isEditing ? (
<>
>
) : (
<>
>
)}
{isEditing ? (
setName(e.target.value)}
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc]"
placeholder="File name"
/>
) : (
<>
{file.name}
{file.description && (
{file.description}
)}
>
)}
{/* Content */}
{/* Summary Section */}
{file.summary && (
)}
{/* Body Content */}
Content
{/* Collapsible Transcript Section */}
{transcriptExpanded && (
{file.transcript.length === 0 ? (
No transcript entries.
) : (
file.transcript.map((entry) => (
[{entry.start.toFixed(2)}s - {entry.end.toFixed(2)}s]
{entry.speaker}
{entry.text}
))
)}
)}
);
}