diff --git a/app/bots/legal-expert/components/demo/WorkspaceDashboard.tsx b/app/bots/legal-expert/components/demo/WorkspaceDashboard.tsx index 30e8ba4..611d8b6 100644 --- a/app/bots/legal-expert/components/demo/WorkspaceDashboard.tsx +++ b/app/bots/legal-expert/components/demo/WorkspaceDashboard.tsx @@ -1,25 +1,18 @@ 'use client'; import React, { useState, useEffect } from 'react'; -import { UploadedFile, LawyerProfile } from './types'; +import { type UploadedFile, type LawyerProfile, type ChatMessage, type CategoryWithFiles, type WorkspaceViewMode } from './types'; import { FILE_CATEGORIES } from './constants'; - -interface ChatMessage { - id: string; - sender: string; - senderName: string; - avatar: string; - content: string; - timestamp: Date; -} - -interface CategoryWithFiles { - id: string; - title: string; - icon: string; - files: UploadedFile[]; - count: number; -} +import { + WorkspaceHeader, + WorkspaceSidebar, + OverviewView, + FilesView, + ChatView, + TimelineView, + SettingsView, + getAIResponse, +} from './workspace'; interface WorkspaceDashboardProps { files: UploadedFile[]; @@ -31,42 +24,6 @@ interface WorkspaceDashboardProps { onFileVisibilityChange: (fileId: string, visibility: string) => void; } -type ViewMode = 'overview' | 'files' | 'chat' | 'timeline' | 'settings'; - -interface OverviewViewProps { - files: UploadedFile[]; - categoriesWithFiles: CategoryWithFiles[]; - caseDescription: string; - setViewMode: (mode: ViewMode) => void; -} - -interface FilesViewProps { - files: UploadedFile[]; - categoriesWithFiles: CategoryWithFiles[]; - selectedFile: string | null; - setSelectedFile: (id: string | null) => void; - onFileDelete: (fileId: string) => void; - onFileVisibilityChange: (fileId: string, visibility: string) => void; -} - -interface ChatViewProps { - messages: ChatMessage[]; - inputMessage: string; - setInputMessage: (msg: string) => void; - handleSendMessage: () => void; - isTyping: boolean; - lawyer: LawyerProfile; -} - -interface TimelineViewProps { - files: UploadedFile[]; - messages: ChatMessage[]; -} - -interface SettingsViewProps { - lawyer: LawyerProfile; -} - const WorkspaceDashboard: React.FC = ({ files, lawyer, @@ -74,9 +31,9 @@ const WorkspaceDashboard: React.FC = ({ onClose, onFileUpload, onFileDelete, - onFileVisibilityChange + onFileVisibilityChange, }) => { - const [viewMode, setViewMode] = useState('overview'); + const [viewMode, setViewMode] = useState('overview'); const [selectedFile, setSelectedFile] = useState(null); const [isDragging, setIsDragging] = useState(false); const [showAnimation, setShowAnimation] = useState(false); @@ -91,14 +48,14 @@ const WorkspaceDashboard: React.FC = ({ // Initial welcome messages useEffect(() => { - const welcomeMessages = [ + const welcomeMessages: ChatMessage[] = [ { id: '1', sender: 'ai', senderName: 'Lex AI', avatar: '🤖', content: `Welcome to your secure data room! I've analyzed your case and organized ${files.length} files. How can I help you today?`, - timestamp: new Date() + timestamp: new Date(), }, { id: '2', @@ -106,18 +63,18 @@ const WorkspaceDashboard: React.FC = ({ senderName: lawyer.username, avatar: lawyer.avatar, content: `Hi! I'm ${lawyer.username}, your assigned attorney. I've reviewed your case and I'm here to assist. Feel free to ask me anything.`, - timestamp: new Date() - } + timestamp: new Date(), + }, ]; setMessages(welcomeMessages); }, [lawyer, files.length]); // File categories with counts - const categoriesWithFiles = FILE_CATEGORIES.map(cat => ({ + const categoriesWithFiles: CategoryWithFiles[] = FILE_CATEGORIES.map((cat) => ({ ...cat, - files: files.filter(f => f.category === cat.id), - count: files.filter(f => f.category === cat.id).length - })).filter(cat => cat.count > 0); + files: files.filter((f) => f.category === cat.id), + count: files.filter((f) => f.category === cat.id).length, + })).filter((cat) => cat.count > 0); // Handle file drop const handleDrop = (e: React.DragEvent) => { @@ -132,7 +89,7 @@ const WorkspaceDashboard: React.FC = ({ size: file.size, category: 'other', status: 'uploading' as const, - visibility: 'private' + visibility: 'private', })); // Simulate upload @@ -148,31 +105,31 @@ const WorkspaceDashboard: React.FC = ({ const handleSendMessage = () => { if (!inputMessage.trim()) return; - const userMessage = { + const userMessage: ChatMessage = { id: `msg-${Date.now()}`, sender: 'user', senderName: 'You', avatar: '👤', content: inputMessage, - timestamp: new Date() + timestamp: new Date(), }; - setMessages(prev => [...prev, userMessage]); + setMessages((prev) => [...prev, userMessage]); setInputMessage(''); // AI response setIsTyping(true); setTimeout(() => { setIsTyping(false); - const aiResponse = { + const aiResponse: ChatMessage = { id: `msg-${Date.now()}-ai`, sender: 'ai', senderName: 'Lex AI', avatar: '🤖', content: getAIResponse(inputMessage), - timestamp: new Date() + timestamp: new Date(), }; - setMessages(prev => [...prev, aiResponse]); + setMessages((prev) => [...prev, aiResponse]); }, 2000); }; @@ -181,7 +138,10 @@ const WorkspaceDashboard: React.FC = ({ className={`fixed inset-0 z-50 bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 transition-all duration-700 ${ showAnimation ? 'opacity-100' : 'opacity-0' }`} - onDragOver={(e) => { e.preventDefault(); setIsDragging(true); }} + onDragOver={(e) => { + e.preventDefault(); + setIsDragging(true); + }} onDragLeave={() => setIsDragging(false)} onDrop={handleDrop} > @@ -191,100 +151,16 @@ const WorkspaceDashboard: React.FC = ({
- {/* Header */} -
-
-
-
-
-
- L -
-
-

Lex Workspace

-

Private Data Room • End-to-End Encrypted

-
-
-
- -
- {/* Lawyer info */} -
- {lawyer.avatar} -
-

{lawyer.username}

-

- - Online -

-
-
- - {/* Close button */} - -
-
-
-
+ {/* Main Content */}
- {/* Sidebar Navigation */} - + {/* Main View */}
@@ -299,7 +175,6 @@ const WorkspaceDashboard: React.FC = ({ {viewMode === 'files' && ( = ({ /> )} - {viewMode === 'timeline' && ( - - )} + {viewMode === 'timeline' && } - {viewMode === 'settings' && ( - - )} + {viewMode === 'settings' && }
@@ -343,300 +214,4 @@ const WorkspaceDashboard: React.FC = ({ ); }; -// Overview View Component -const OverviewView: React.FC = ({ files, categoriesWithFiles, caseDescription, setViewMode }) => ( -
- {/* Welcome banner */} -
-

Welcome to Your Data Room 🚀

-

Your secure collaborative workspace is ready. All files are encrypted end-to-end.

-
- - {/* Case summary */} -
-

📋 Case Summary

-

{caseDescription}

-
- - {/* Quick actions */} -
- {([ - { icon: '📁', title: 'Files', count: files.length, color: 'from-blue-500 to-cyan-500', view: 'files' as const }, - { icon: '💬', title: 'Chat', count: '24/7', color: 'from-purple-500 to-pink-500', view: 'chat' as const }, - { icon: '📅', title: 'Timeline', count: 'Live', color: 'from-green-500 to-emerald-500', view: 'timeline' as const }, - { icon: '⚙️', title: 'Settings', count: 'Manage', color: 'from-orange-500 to-red-500', view: 'settings' as const } - ] as const).map((action) => ( - - ))} -
- - {/* File categories preview */} -
-

📂 File Categories

-
- {categoriesWithFiles.map((cat: { id: string; title: string; icon: string; count: number }) => ( -
-
- {cat.icon} - {cat.count} -
-

{cat.title}

-
- ))} -
-
-
-); - -// Files View Component -const FilesView: React.FC = ({ - files: _files, - categoriesWithFiles, - selectedFile, - setSelectedFile, - onFileDelete, - onFileVisibilityChange -}) => ( -
-
-

📁 File Management

- -
- - {categoriesWithFiles.map((category: { id: string; title: string; icon: string; count: number; files: UploadedFile[] }) => ( -
-
-
-
- {category.icon} -

{category.title}

- - {category.count} files - -
-
-
- -
- {category.files.map((file: UploadedFile) => ( -
-
📄
-
-

{file.name}

-
- {formatFileSize(file.size)} - -
-
-
- - -
-
- ))} -
-
- ))} -
-); - -// Chat View Component -const ChatView: React.FC = ({ messages, inputMessage, setInputMessage, handleSendMessage, isTyping, lawyer }) => ( -
-
-

💬 Live Chat

-

AI + {lawyer.username} • No appointments needed

-
- -
- {messages.map((msg: { id: string; sender: string; senderName: string; avatar: string; content: string; timestamp: Date }) => ( -
- {msg.sender !== 'user' && ( -
- {msg.avatar} -
- )} -
-

{msg.senderName}

-

{msg.content}

-

{msg.timestamp.toLocaleTimeString()}

-
-
- ))} - {isTyping && ( -
-
- 🤖 -
-
-
- - - -
-
-
- )} -
- -
-
- setInputMessage(e.target.value)} - onKeyPress={(e) => e.key === 'Enter' && handleSendMessage()} - placeholder="Ask AI or your lawyer anything..." - className="flex-1 bg-slate-900 text-white px-4 py-3 rounded-lg border border-slate-700 focus:border-blue-500 focus:outline-none" - /> - -
-
-
-); - -// Timeline View Component -const TimelineView: React.FC = ({ files, messages }) => ( -
-

📅 Activity Timeline

-
- {[...messages, ...files].sort((a, b) => - new Date(b.timestamp || Date.now()).getTime() - new Date(a.timestamp || Date.now()).getTime() - ).slice(0, 20).map((item, idx) => ( -
-
{'content' in item ? '💬' : '📄'}
-
-

- {'content' in item ? `Message from ${item.senderName}` : `File uploaded: ${item.name}`} -

-

- {new Date(item.timestamp || Date.now()).toLocaleString()} -

-
-
- ))} -
-
-); - -// Settings View Component -const SettingsView: React.FC = ({ lawyer }) => ( -
-

⚙️ Workspace Settings

- -
-

🔐 Privacy & Access Control

-
- {[ - { role: 'Owner (You)', access: 'Full Access', icon: '👤' }, - { role: `Attorney (${lawyer.username})`, access: 'Full Access', icon: lawyer.avatar }, - { role: 'Paralegal', access: 'Limited Access', icon: '📝' }, - { role: 'Advisor', access: 'Read Only', icon: '👥' } - ].map((member) => ( -
-
- {member.icon} -
-

{member.role}

-

{member.access}

-
-
- -
- ))} -
-
- -
-

🔔 Notifications

-
- {[ - { label: 'Email notifications', enabled: true }, - { label: 'Push notifications', enabled: true }, - { label: 'SMS alerts', enabled: false } - ].map((setting) => ( -
- {setting.label} -
-
-
-
- ))} -
-
-
-); - -// Helper functions -function formatFileSize(bytes: number): string { - if (bytes === 0) return '0 Bytes'; - const k = 1024; - const sizes = ['Bytes', 'KB', 'MB', 'GB']; - const i = Math.floor(Math.log(bytes) / Math.log(k)); - return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i]; -} - -function formatTotalSize(files: UploadedFile[]): string { - const total = files.reduce((acc, f) => acc + f.size, 0); - return formatFileSize(total); -} - -function getAIResponse(message: string): string { - const responses: Record = { - 'help': 'I can help you with document analysis, legal research, deadline tracking, and more. What do you need?', - 'file': 'I\'ve analyzed all your files and organized them into categories. Would you like me to explain any specific document?', - 'deadline': 'Based on your case, I\'ve identified several important deadlines. Would you like me to set up reminders?', - 'default': 'I understand your question. Let me analyze your case files and provide you with a detailed answer. Your lawyer will also be notified if this requires expert legal advice.' - }; - - const lowerMsg = message.toLowerCase(); - for (const [key, response] of Object.entries(responses)) { - if (lowerMsg.includes(key)) return response; - } - return responses.default; -} - export default WorkspaceDashboard; diff --git a/app/bots/legal-expert/components/demo/types.ts b/app/bots/legal-expert/components/demo/types.ts index b4ae81e..53e7dca 100644 --- a/app/bots/legal-expert/components/demo/types.ts +++ b/app/bots/legal-expert/components/demo/types.ts @@ -46,3 +46,23 @@ export interface WorkspaceSection { files: UploadedFile[]; aiSuggestion?: string; } + +// Workspace Dashboard types +export interface ChatMessage { + id: string; + sender: string; + senderName: string; + avatar: string; + content: string; + timestamp: Date; +} + +export interface CategoryWithFiles { + id: string; + title: string; + icon: string; + files: UploadedFile[]; + count: number; +} + +export type WorkspaceViewMode = 'overview' | 'files' | 'chat' | 'timeline' | 'settings'; diff --git a/app/bots/legal-expert/components/demo/workspace/ChatView.tsx b/app/bots/legal-expert/components/demo/workspace/ChatView.tsx new file mode 100644 index 0000000..4413f87 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/ChatView.tsx @@ -0,0 +1,81 @@ +import { type FC } from 'react'; +import { type ChatMessage, type LawyerProfile } from '../types'; + +interface ChatViewProps { + messages: ChatMessage[]; + inputMessage: string; + setInputMessage: (msg: string) => void; + handleSendMessage: () => void; + isTyping: boolean; + lawyer: LawyerProfile; +} + +export const ChatView: FC = ({ + messages, + inputMessage, + setInputMessage, + handleSendMessage, + isTyping, + lawyer, +}) => { + return ( +
+
+

💬 Live Chat

+

AI + {lawyer.username} • No appointments needed

+
+ +
+ {messages.map((msg) => ( +
+ {msg.sender !== 'user' && ( +
+ {msg.avatar} +
+ )} +
+

{msg.senderName}

+

{msg.content}

+

{msg.timestamp.toLocaleTimeString()}

+
+
+ ))} + {isTyping && ( +
+
+ 🤖 +
+
+
+ + + +
+
+
+ )} +
+ +
+
+ setInputMessage(e.target.value)} + onKeyPress={(e) => e.key === 'Enter' && handleSendMessage()} + placeholder="Ask AI or your lawyer anything..." + className="flex-1 bg-slate-900 text-white px-4 py-3 rounded-lg border border-slate-700 focus:border-blue-500 focus:outline-none" + /> + +
+
+
+ ); +}; diff --git a/app/bots/legal-expert/components/demo/workspace/FilesView.tsx b/app/bots/legal-expert/components/demo/workspace/FilesView.tsx new file mode 100644 index 0000000..d831e32 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/FilesView.tsx @@ -0,0 +1,94 @@ +import { type FC } from 'react'; +import { type UploadedFile, type CategoryWithFiles } from '../types'; +import { formatFileSize } from './workspaceUtils'; + +interface FilesViewProps { + categoriesWithFiles: CategoryWithFiles[]; + selectedFile: string | null; + setSelectedFile: (id: string | null) => void; + onFileDelete: (fileId: string) => void; + onFileVisibilityChange: (fileId: string, visibility: string) => void; +} + +export const FilesView: FC = ({ + categoriesWithFiles, + selectedFile, + setSelectedFile, + onFileDelete, + onFileVisibilityChange, +}) => { + return ( +
+
+

📁 File Management

+ +
+ + {categoriesWithFiles.map((category) => ( +
+
+
+
+ {category.icon} +

{category.title}

+ + {category.count} files + +
+
+
+ +
+ {category.files.map((file: UploadedFile) => ( +
+
📄
+
+

{file.name}

+
+ {formatFileSize(file.size)} + +
+
+
+ + +
+
+ ))} +
+
+ ))} +
+ ); +}; diff --git a/app/bots/legal-expert/components/demo/workspace/OverviewView.tsx b/app/bots/legal-expert/components/demo/workspace/OverviewView.tsx new file mode 100644 index 0000000..ca7c4b6 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/OverviewView.tsx @@ -0,0 +1,103 @@ +import { type FC } from 'react'; +import { type UploadedFile, type CategoryWithFiles, type WorkspaceViewMode } from '../types'; + +interface OverviewViewProps { + files: UploadedFile[]; + categoriesWithFiles: CategoryWithFiles[]; + caseDescription: string; + setViewMode: (mode: WorkspaceViewMode) => void; +} + +const QUICK_ACTIONS = [ + { icon: '📁', title: 'Files', color: 'from-blue-500 to-cyan-500', view: 'files' as const }, + { icon: '💬', title: 'Chat', color: 'from-purple-500 to-pink-500', view: 'chat' as const }, + { + icon: '📅', + title: 'Timeline', + color: 'from-green-500 to-emerald-500', + view: 'timeline' as const, + }, + { + icon: '⚙️', + title: 'Settings', + color: 'from-orange-500 to-red-500', + view: 'settings' as const, + }, +] as const; + +export const OverviewView: FC = ({ + files, + categoriesWithFiles, + caseDescription, + setViewMode, +}) => { + const getActionCount = (view: WorkspaceViewMode): string | number => { + switch (view) { + case 'files': + return files.length; + case 'chat': + return '24/7'; + case 'timeline': + return 'Live'; + case 'settings': + return 'Manage'; + default: + return ''; + } + }; + + return ( +
+ {/* Welcome banner */} +
+

Welcome to Your Data Room 🚀

+

+ Your secure collaborative workspace is ready. All files are encrypted end-to-end. +

+
+ + {/* Case summary */} +
+

📋 Case Summary

+

{caseDescription}

+
+ + {/* Quick actions */} +
+ {QUICK_ACTIONS.map((action) => ( + + ))} +
+ + {/* File categories preview */} +
+

📂 File Categories

+
+ {categoriesWithFiles.map((cat) => ( +
+
+ {cat.icon} + + {cat.count} + +
+

{cat.title}

+
+ ))} +
+
+
+ ); +}; diff --git a/app/bots/legal-expert/components/demo/workspace/SettingsView.tsx b/app/bots/legal-expert/components/demo/workspace/SettingsView.tsx new file mode 100644 index 0000000..7147e48 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/SettingsView.tsx @@ -0,0 +1,80 @@ +import { type FC } from 'react'; +import { type LawyerProfile } from '../types'; + +interface SettingsViewProps { + lawyer: LawyerProfile; +} + +interface TeamMember { + role: string; + access: string; + icon: string; +} + +interface NotificationSetting { + label: string; + enabled: boolean; +} + +export const SettingsView: FC = ({ lawyer }) => { + const teamMembers: TeamMember[] = [ + { role: 'Owner (You)', access: 'Full Access', icon: '👤' }, + { role: `Attorney (${lawyer.username})`, access: 'Full Access', icon: lawyer.avatar }, + { role: 'Paralegal', access: 'Limited Access', icon: '📝' }, + { role: 'Advisor', access: 'Read Only', icon: '👥' }, + ]; + + const notificationSettings: NotificationSetting[] = [ + { label: 'Email notifications', enabled: true }, + { label: 'Push notifications', enabled: true }, + { label: 'SMS alerts', enabled: false }, + ]; + + return ( +
+

⚙️ Workspace Settings

+ +
+

🔐 Privacy & Access Control

+
+ {teamMembers.map((member) => ( +
+
+ {member.icon} +
+

{member.role}

+

{member.access}

+
+
+ +
+ ))} +
+
+ +
+

🔔 Notifications

+
+ {notificationSettings.map((setting) => ( +
+ {setting.label} +
+
+
+
+ ))} +
+
+
+ ); +}; diff --git a/app/bots/legal-expert/components/demo/workspace/TimelineView.tsx b/app/bots/legal-expert/components/demo/workspace/TimelineView.tsx new file mode 100644 index 0000000..6f852d9 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/TimelineView.tsx @@ -0,0 +1,50 @@ +import { type FC } from 'react'; +import { type UploadedFile, type ChatMessage } from '../types'; + +interface TimelineViewProps { + files: UploadedFile[]; + messages: ChatMessage[]; +} + +type TimelineItem = + | (ChatMessage & { itemType: 'message' }) + | (UploadedFile & { itemType: 'file' }); + +export const TimelineView: FC = ({ files, messages }) => { + // Combine and sort items by timestamp + const timelineItems: TimelineItem[] = [ + ...messages.map((m) => ({ ...m, itemType: 'message' as const })), + ...files.map((f) => ({ ...f, itemType: 'file' as const, timestamp: f.timestamp || new Date() })), + ] + .sort( + (a, b) => + new Date(b.timestamp || Date.now()).getTime() - new Date(a.timestamp || Date.now()).getTime() + ) + .slice(0, 20); + + return ( +
+

📅 Activity Timeline

+
+ {timelineItems.map((item, idx) => ( +
+
{item.itemType === 'message' ? '💬' : '📄'}
+
+

+ {item.itemType === 'message' + ? `Message from ${(item as ChatMessage).senderName}` + : `File uploaded: ${(item as UploadedFile).name}`} +

+

+ {new Date(item.timestamp || Date.now()).toLocaleString()} +

+
+
+ ))} +
+
+ ); +}; diff --git a/app/bots/legal-expert/components/demo/workspace/WorkspaceHeader.tsx b/app/bots/legal-expert/components/demo/workspace/WorkspaceHeader.tsx new file mode 100644 index 0000000..c3cff25 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/WorkspaceHeader.tsx @@ -0,0 +1,61 @@ +import { type FC } from 'react'; +import { type LawyerProfile } from '../types'; + +interface WorkspaceHeaderProps { + lawyer: LawyerProfile; + onClose: () => void; +} + +export const WorkspaceHeader: FC = ({ lawyer, onClose }) => { + return ( +
+
+
+
+
+
+ L +
+
+

Lex Workspace

+

+ Private Data Room • End-to-End Encrypted +

+
+
+
+ +
+ {/* Lawyer info */} +
+ {lawyer.avatar} +
+

{lawyer.username}

+

+ + Online +

+
+
+ + {/* Close button */} + +
+
+
+
+ ); +}; diff --git a/app/bots/legal-expert/components/demo/workspace/WorkspaceSidebar.tsx b/app/bots/legal-expert/components/demo/workspace/WorkspaceSidebar.tsx new file mode 100644 index 0000000..d1831b5 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/WorkspaceSidebar.tsx @@ -0,0 +1,78 @@ +import { type FC } from 'react'; +import { type UploadedFile, type ChatMessage, type WorkspaceViewMode } from '../types'; +import { formatTotalSize } from './workspaceUtils'; + +interface WorkspaceSidebarProps { + viewMode: WorkspaceViewMode; + setViewMode: (mode: WorkspaceViewMode) => void; + files: UploadedFile[]; + messages: ChatMessage[]; +} + +const NAV_ITEMS: { id: WorkspaceViewMode; icon: string; label: string; hasBadge?: boolean }[] = [ + { id: 'overview', icon: '🏠', label: 'Overview' }, + { id: 'files', icon: '📁', label: 'Files', hasBadge: true }, + { id: 'chat', icon: '💬', label: 'Chat', hasBadge: true }, + { id: 'timeline', icon: '📅', label: 'Timeline' }, + { id: 'settings', icon: '⚙️', label: 'Settings' }, +]; + +export const WorkspaceSidebar: FC = ({ + viewMode, + setViewMode, + files, + messages, +}) => { + const getBadgeCount = (id: WorkspaceViewMode): number | undefined => { + if (id === 'files') return files.length; + if (id === 'chat') return messages.length; + return undefined; + }; + + return ( + + ); +}; diff --git a/app/bots/legal-expert/components/demo/workspace/index.ts b/app/bots/legal-expert/components/demo/workspace/index.ts new file mode 100644 index 0000000..2fdd969 --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/index.ts @@ -0,0 +1,8 @@ +export { WorkspaceHeader } from './WorkspaceHeader'; +export { WorkspaceSidebar } from './WorkspaceSidebar'; +export { OverviewView } from './OverviewView'; +export { FilesView } from './FilesView'; +export { ChatView } from './ChatView'; +export { TimelineView } from './TimelineView'; +export { SettingsView } from './SettingsView'; +export { formatFileSize, formatTotalSize, getAIResponse } from './workspaceUtils'; diff --git a/app/bots/legal-expert/components/demo/workspace/workspaceUtils.ts b/app/bots/legal-expert/components/demo/workspace/workspaceUtils.ts new file mode 100644 index 0000000..68bf54e --- /dev/null +++ b/app/bots/legal-expert/components/demo/workspace/workspaceUtils.ts @@ -0,0 +1,40 @@ +import { type UploadedFile } from '../types'; + +/** + * Format file size in human-readable format + */ +export function formatFileSize(bytes: number): string { + if (bytes === 0) return '0 Bytes'; + const k = 1024; + const sizes = ['Bytes', 'KB', 'MB', 'GB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i]; +} + +/** + * Calculate and format total size of files + */ +export function formatTotalSize(files: UploadedFile[]): string { + const total = files.reduce((acc, f) => acc + f.size, 0); + return formatFileSize(total); +} + +/** + * Get AI response based on message content + */ +export function getAIResponse(message: string): string { + const responses: Record = { + help: "I can help you with document analysis, legal research, deadline tracking, and more. What do you need?", + file: "I've analyzed all your files and organized them into categories. Would you like me to explain any specific document?", + deadline: + "Based on your case, I've identified several important deadlines. Would you like me to set up reminders?", + default: + "I understand your question. Let me analyze your case files and provide you with a detailed answer. Your lawyer will also be notified if this requires expert legal advice.", + }; + + const lowerMsg = message.toLowerCase(); + for (const [key, response] of Object.entries(responses)) { + if (lowerMsg.includes(key)) return response; + } + return responses.default; +}