/** * StudioContextFiles - Context document upload and display */ import React, { useState, useRef } from 'react'; import { FileText, Upload, Trash2, Loader2 } from 'lucide-react'; import { intakeApi } from '../../api/intake'; interface StudioContextFilesProps { draftId: string; files: string[]; onUploadComplete: () => void; } export const StudioContextFiles: React.FC = ({ draftId, files, onUploadComplete, }) => { const [isUploading, setIsUploading] = useState(false); const [deleting, setDeleting] = useState(null); const fileInputRef = useRef(null); const VALID_EXTENSIONS = ['.md', '.txt', '.pdf', '.json', '.csv', '.docx']; const handleFileSelect = async (e: React.ChangeEvent) => { const selectedFiles = Array.from(e.target.files || []); if (selectedFiles.length === 0) return; e.target.value = ''; setIsUploading(true); try { await intakeApi.uploadContextFiles(draftId, selectedFiles); onUploadComplete(); } catch (err) { console.error('Failed to upload context files:', err); } finally { setIsUploading(false); } }; const deleteFile = async (filename: string) => { setDeleting(filename); try { await intakeApi.deleteContextFile(draftId, filename); onUploadComplete(); } catch (err) { console.error('Failed to delete context file:', err); } finally { setDeleting(null); } }; const getFileIcon = (_filename: string) => { return ; }; return (
{/* File List */} {files.length > 0 && (
{files.map((name) => (
{getFileIcon(name)} {name}
))}
)} {/* Upload Button */}
); }; export default StudioContextFiles;