// Primus IQ — Project detail, Library, Apps, Search, Add Sources modal const extColors = { pdf: '#B23A48', xlsx: '#2E6F40', pptx: '#C76A23', docx: '#2A5A9E', png: '#7A4FB3', jpg: '#7A4FB3', mp4: '#1F4A6B', txt: '#666666', }; const PRACTICES = [ 'Public Policy Realization', 'Sector Potential Realization', 'Impact Realization', 'Economic Potential Realization', 'Data & Digital Strategy', 'Transaction Realization', ]; const UPLOADED_SEED = [ { id: 'u1', name: 'Sector Outlook · KSA fintech.pdf', size: '8.6 MB', ext: 'pdf', conf: 'public', practice: 'Sector Potential Realization', added: '12 May' }, { id: 'u2', name: 'Acme Financial Model v4.xlsx', size: '4.2 MB', ext: 'xlsx', conf: 'strict', practice: 'Transaction Realization', added: '10 May' }, { id: 'u3', name: 'Pitch Storyline draft.pptx', size: '12.0 MB', ext: 'pptx', conf: 'internal', practice: 'Sector Potential Realization', added: '08 May' }, { id: 'u4', name: 'CFO interview · transcript.docx', size: '180 KB', ext: 'docx', conf: 'client', practice: 'Sector Potential Realization', added: '04 May' }, { id: 'u5', name: 'Cost Build · Phase 1.xlsx', size: '2.4 MB', ext: 'xlsx', conf: 'client', practice: 'Transaction Realization', added: '02 May' }, ]; // ────────────────────────────────────────────────────────────────────────────── // Project Detail — 50/50 split. LEFT = upload sources. RIGHT = files queue. // ────────────────────────────────────────────────────────────────────────────── const ScreenProjectDetail = ({ setRoute, openTagging, openSharePoint, openTextInput, openUrlInput, openInvite, openEditProject, uploadedFiles, removeFile, downloadFile, activeProject, projectMembers }) => { const [dragHover, setDragHover] = React.useState(false); const [pendingCount, setPendingCount] = React.useState(0); const [tab, setTab] = React.useState('chats'); // 'chats' | 'sources' const [chats, setChats] = React.useState([]); // local chat sessions const [activeChat, setActiveChat] = React.useState(null); // currently open chat const [composerVal, setComposerVal] = React.useState(''); const [composerFocused, setComposerFocused] = React.useState(false); const [filter, setFilter] = React.useState(''); const projectName = activeProject?.name || 'Project'; const projectPractice = activeProject?.practice || ''; const fq = filter.trim().toLowerCase(); const filteredChats = fq ? chats.filter(c => `${c.title || ''} ${c.preview || ''}`.toLowerCase().includes(fq)) : chats; const filteredFiles = fq ? uploadedFiles.filter(f => (f.name || '').toLowerCase().includes(fq)) : uploadedFiles; React.useEffect(() => { if (!activeProject?.id) return; PrimusAPI.listJoinRequests(activeProject.id) .then(data => setPendingCount((data || []).length)) .catch(() => setPendingCount(0)); }, [activeProject?.id]); // Reset chats when active project changes React.useEffect(() => { setChats([]); setActiveChat(null); }, [activeProject?.id]); const submitComposer = () => { const q = composerVal.trim(); if (!q) return; const id = 'c-' + Date.now(); const newChat = { id, title: q.length > 60 ? q.slice(0, 60) + '…' : q, preview: q, updated: 'just now', messages: [{ role: 'user', text: q }], }; setChats(prev => [newChat, ...prev]); setComposerVal(''); setActiveChat(newChat); setTab('chats'); }; // ── Full-screen chat view (opened from this project) ── if (activeChat) { return ( setActiveChat(null)} onSend={(text) => { setActiveChat(prev => ({ ...prev, messages: [...(prev.messages || []), { role: 'user', text }] })); setChats(prev => prev.map(c => c.id === activeChat.id ? { ...c, preview: text, updated: 'just now' } : c)); }} /> ); } return (
{/* Crumb */}
/ {projectName}
{/* Header */}

{projectName}

{projectPractice && {projectPractice}} · {uploadedFiles.length} files
{projectMembers && projectMembers.length > 0 && (
{projectMembers.slice(0, 3).map((m, i) => (
{(m.full_name || '?')[0].toUpperCase()}
))} {projectMembers.length > 3 && (
+{projectMembers.length - 3}
)}
)}
{/* TOP ROW: New chat composer (left) + Add sources (right) — sized to content */}
{/* LEFT: New chat in */}
New chat in {projectName}
Ask anything — this project's files are referenced automatically.