mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-05 03:39:10 +01:00
refactor: split WorkspaceDashboard into focused sub-components
Extract WorkspaceDashboard.tsx (642→219 lines) into workspace/ directory: - WorkspaceHeader: header with lawyer info and close button - WorkspaceSidebar: navigation with stats - OverviewView: welcome banner, case summary, quick actions - FilesView: file management with categories - ChatView: live chat interface - TimelineView: activity timeline - SettingsView: privacy and notification settings - workspaceUtils: helper functions (formatFileSize, getAIResponse) Part of P2 - Large Component Breakdown Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41d002975b
commit
757b28650b
11 files changed
+656
-466
No files matched your search
@@ -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<WorkspaceDashboardProps> = ({
|
||||
files,
|
||||
lawyer,
|
||||
@@ -74,9 +31,9 @@ const WorkspaceDashboard: React.FC<WorkspaceDashboardProps> = ({
|
||||
onClose,
|
||||
onFileUpload,
|
||||
onFileDelete,
|
||||
onFileVisibilityChange
|
||||
onFileVisibilityChange,
|
||||
}) => {
|
||||
const [viewMode, setViewMode] = useState<ViewMode>('overview');
|
||||
const [viewMode, setViewMode] = useState<WorkspaceViewMode>('overview');
|
||||
const [selectedFile, setSelectedFile] = useState<string | null>(null);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const [showAnimation, setShowAnimation] = useState(false);
|
||||
@@ -91,14 +48,14 @@ const WorkspaceDashboard: React.FC<WorkspaceDashboardProps> = ({
|
||||
|
||||
// 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<WorkspaceDashboardProps> = ({
|
||||
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<WorkspaceDashboardProps> = ({
|
||||
size: file.size,
|
||||
category: 'other',
|
||||
status: 'uploading' as const,
|
||||
visibility: 'private'
|
||||
visibility: 'private',
|
||||
}));
|
||||
|
||||
// Simulate upload
|
||||
@@ -148,31 +105,31 @@ const WorkspaceDashboard: React.FC<WorkspaceDashboardProps> = ({
|
||||
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<WorkspaceDashboardProps> = ({
|
||||
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<WorkspaceDashboardProps> = ({
|
||||
<div className="absolute bottom-1/4 right-1/4 w-96 h-96 bg-cyan-500 rounded-full blur-3xl animate-pulse delay-700" />
|
||||
</div>
|
||||
|
||||
{/* Header */}
|
||||
<header className="relative border-b border-slate-700 bg-slate-900/50 backdrop-blur-xl">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center text-white font-bold text-xl shadow-lg">
|
||||
L
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="text-xl font-bold text-white">Lex Workspace</h1>
|
||||
<p className="text-xs text-slate-400">Private Data Room • End-to-End Encrypted</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
{/* Lawyer info */}
|
||||
<div className="hidden sm:flex items-center gap-3 px-4 py-2 bg-slate-800 rounded-lg border border-slate-700">
|
||||
<span className="text-2xl">{lawyer.avatar}</span>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-white">{lawyer.username}</p>
|
||||
<p className="text-xs text-green-400 flex items-center gap-1">
|
||||
<span className="w-2 h-2 rounded-full bg-green-400 animate-pulse" />
|
||||
Online
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Close button */}
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-2 hover:bg-slate-800 rounded-lg transition-colors text-slate-400 hover:text-white"
|
||||
title="Exit Workspace"
|
||||
>
|
||||
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<WorkspaceHeader lawyer={lawyer} onClose={onClose} />
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="relative h-[calc(100vh-80px)] flex">
|
||||
{/* Sidebar Navigation */}
|
||||
<aside className="w-20 lg:w-64 bg-slate-900/50 backdrop-blur-xl border-r border-slate-700 flex flex-col">
|
||||
<nav className="flex-1 p-4 space-y-2">
|
||||
{[
|
||||
{ id: 'overview', icon: '🏠', label: 'Overview' },
|
||||
{ id: 'files', icon: '📁', label: 'Files', badge: files.length },
|
||||
{ id: 'chat', icon: '💬', label: 'Chat', badge: messages.length },
|
||||
{ id: 'timeline', icon: '📅', label: 'Timeline' },
|
||||
{ id: 'settings', icon: '⚙️', label: 'Settings' }
|
||||
].map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
onClick={() => setViewMode(item.id as ViewMode)}
|
||||
className={`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-all ${
|
||||
viewMode === item.id
|
||||
? 'bg-gradient-to-r from-blue-600 to-cyan-600 text-white shadow-lg scale-105'
|
||||
: 'text-slate-400 hover:bg-slate-800 hover:text-white'
|
||||
}`}
|
||||
>
|
||||
<span className="text-xl">{item.icon}</span>
|
||||
<span className="hidden lg:block font-medium">{item.label}</span>
|
||||
{item.badge && (
|
||||
<span className="hidden lg:block ml-auto bg-slate-700 text-white text-xs px-2 py-0.5 rounded-full">
|
||||
{item.badge}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{/* Quick Stats */}
|
||||
<div className="hidden lg:block p-4 border-t border-slate-700">
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-slate-400">Files</span>
|
||||
<span className="text-white font-bold">{files.length}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-slate-400">Messages</span>
|
||||
<span className="text-white font-bold">{messages.length}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-slate-400">Storage</span>
|
||||
<span className="text-white font-bold">{formatTotalSize(files)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
<WorkspaceSidebar
|
||||
viewMode={viewMode}
|
||||
setViewMode={setViewMode}
|
||||
files={files}
|
||||
messages={messages}
|
||||
/>
|
||||
|
||||
{/* Main View */}
|
||||
<main className="flex-1 overflow-auto p-4 sm:p-6 lg:p-8">
|
||||
@@ -299,7 +175,6 @@ const WorkspaceDashboard: React.FC<WorkspaceDashboardProps> = ({
|
||||
|
||||
{viewMode === 'files' && (
|
||||
<FilesView
|
||||
files={files}
|
||||
categoriesWithFiles={categoriesWithFiles}
|
||||
selectedFile={selectedFile}
|
||||
setSelectedFile={setSelectedFile}
|
||||
@@ -319,13 +194,9 @@ const WorkspaceDashboard: React.FC<WorkspaceDashboardProps> = ({
|
||||
/>
|
||||
)}
|
||||
|
||||
{viewMode === 'timeline' && (
|
||||
<TimelineView files={files} messages={messages} />
|
||||
)}
|
||||
{viewMode === 'timeline' && <TimelineView files={files} messages={messages} />}
|
||||
|
||||
{viewMode === 'settings' && (
|
||||
<SettingsView lawyer={lawyer} />
|
||||
)}
|
||||
{viewMode === 'settings' && <SettingsView lawyer={lawyer} />}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -343,300 +214,4 @@ const WorkspaceDashboard: React.FC<WorkspaceDashboardProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
// Overview View Component
|
||||
const OverviewView: React.FC<OverviewViewProps> = ({ files, categoriesWithFiles, caseDescription, setViewMode }) => (
|
||||
<div className="space-y-6 animate-fadeIn">
|
||||
{/* Welcome banner */}
|
||||
<div className="bg-gradient-to-r from-blue-600 to-cyan-600 rounded-2xl p-6 text-white">
|
||||
<h2 className="text-2xl font-bold mb-2">Welcome to Your Data Room 🚀</h2>
|
||||
<p className="text-blue-100">Your secure collaborative workspace is ready. All files are encrypted end-to-end.</p>
|
||||
</div>
|
||||
|
||||
{/* Case summary */}
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-3">📋 Case Summary</h3>
|
||||
<p className="text-slate-300 text-sm leading-relaxed">{caseDescription}</p>
|
||||
</div>
|
||||
|
||||
{/* Quick actions */}
|
||||
<div className="grid sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
{([
|
||||
{ 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) => (
|
||||
<button
|
||||
key={action.title}
|
||||
onClick={() => setViewMode(action.view)}
|
||||
className="bg-slate-800/50 backdrop-blur-xl rounded-xl p-6 border border-slate-700 hover:border-slate-600 transition-all hover:scale-105 group"
|
||||
>
|
||||
<div className={`text-4xl mb-3 bg-gradient-to-br ${action.color} bg-clip-text text-transparent`}>
|
||||
{action.icon}
|
||||
</div>
|
||||
<h4 className="text-white font-bold mb-1">{action.title}</h4>
|
||||
<p className="text-slate-400 text-sm">{action.count}</p>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* File categories preview */}
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-4">📂 File Categories</h3>
|
||||
<div className="grid sm:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||
{categoriesWithFiles.map((cat: { id: string; title: string; icon: string; count: number }) => (
|
||||
<div key={cat.id} className="bg-slate-900/50 rounded-lg p-4 border border-slate-700">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-2xl">{cat.icon}</span>
|
||||
<span className="text-xs bg-blue-600 text-white px-2 py-1 rounded-full">{cat.count}</span>
|
||||
</div>
|
||||
<p className="text-sm text-white font-medium">{cat.title}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// Files View Component
|
||||
const FilesView: React.FC<FilesViewProps> = ({
|
||||
files: _files,
|
||||
categoriesWithFiles,
|
||||
selectedFile,
|
||||
setSelectedFile,
|
||||
onFileDelete,
|
||||
onFileVisibilityChange
|
||||
}) => (
|
||||
<div className="space-y-6 animate-fadeIn">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="text-2xl font-bold text-white">📁 File Management</h2>
|
||||
<button className="px-4 py-2 bg-gradient-to-r from-blue-600 to-cyan-600 text-white rounded-lg font-medium hover:shadow-lg transition-all">
|
||||
+ Upload Files
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{categoriesWithFiles.map((category: { id: string; title: string; icon: string; count: number; files: UploadedFile[] }) => (
|
||||
<div key={category.id} className="bg-slate-800/50 backdrop-blur-xl rounded-2xl border border-slate-700 overflow-hidden">
|
||||
<div className="px-6 py-4 bg-slate-900/50 border-b border-slate-700">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-2xl">{category.icon}</span>
|
||||
<h3 className="text-lg font-bold text-white">{category.title}</h3>
|
||||
<span className="text-xs bg-slate-700 text-slate-300 px-2 py-1 rounded-full">
|
||||
{category.count} files
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4 space-y-2">
|
||||
{category.files.map((file: UploadedFile) => (
|
||||
<div
|
||||
key={file.id}
|
||||
className={`flex items-center gap-4 p-4 rounded-lg border transition-all ${
|
||||
selectedFile === file.id
|
||||
? 'bg-blue-600/20 border-blue-500'
|
||||
: 'bg-slate-900/30 border-slate-700 hover:border-slate-600'
|
||||
}`}
|
||||
>
|
||||
<div className="text-3xl">📄</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-white font-medium truncate">{file.name}</p>
|
||||
<div className="flex items-center gap-4 mt-1">
|
||||
<span className="text-xs text-slate-400">{formatFileSize(file.size)}</span>
|
||||
<select
|
||||
value={file.visibility || 'private'}
|
||||
onChange={(e) => onFileVisibilityChange(file.id, e.target.value)}
|
||||
className="text-xs bg-slate-700 text-white px-2 py-1 rounded border border-slate-600"
|
||||
>
|
||||
<option value="private">🔒 Private</option>
|
||||
<option value="lawyer">👨⚖️ Lawyer Only</option>
|
||||
<option value="team">👥 Team</option>
|
||||
<option value="public">🌐 Public</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={() => setSelectedFile(file.id)}
|
||||
className="p-2 hover:bg-slate-700 rounded-lg text-slate-400 hover:text-white transition-colors"
|
||||
>
|
||||
👁️
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onFileDelete(file.id)}
|
||||
className="p-2 hover:bg-red-600/20 rounded-lg text-slate-400 hover:text-red-400 transition-colors"
|
||||
>
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
// Chat View Component
|
||||
const ChatView: React.FC<ChatViewProps> = ({ messages, inputMessage, setInputMessage, handleSendMessage, isTyping, lawyer }) => (
|
||||
<div className="h-full flex flex-col bg-slate-800/50 backdrop-blur-xl rounded-2xl border border-slate-700">
|
||||
<div className="px-6 py-4 border-b border-slate-700">
|
||||
<h2 className="text-xl font-bold text-white">💬 Live Chat</h2>
|
||||
<p className="text-sm text-slate-400">AI + {lawyer.username} • No appointments needed</p>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-auto p-6 space-y-4">
|
||||
{messages.map((msg: { id: string; sender: string; senderName: string; avatar: string; content: string; timestamp: Date }) => (
|
||||
<div key={msg.id} className={`flex gap-3 ${msg.sender === 'user' ? 'justify-end' : ''}`}>
|
||||
{msg.sender !== 'user' && (
|
||||
<div className="w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center text-white flex-shrink-0">
|
||||
{msg.avatar}
|
||||
</div>
|
||||
)}
|
||||
<div className={`max-w-md ${msg.sender === 'user' ? 'bg-blue-600' : 'bg-slate-700'} rounded-2xl px-4 py-3`}>
|
||||
<p className="text-xs text-slate-300 mb-1">{msg.senderName}</p>
|
||||
<p className="text-white text-sm">{msg.content}</p>
|
||||
<p className="text-xs text-slate-400 mt-1">{msg.timestamp.toLocaleTimeString()}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{isTyping && (
|
||||
<div className="flex gap-3">
|
||||
<div className="w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center">
|
||||
🤖
|
||||
</div>
|
||||
<div className="bg-slate-700 rounded-2xl px-4 py-3">
|
||||
<div className="flex gap-1">
|
||||
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce" />
|
||||
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce delay-100" />
|
||||
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce delay-200" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="p-4 border-t border-slate-700">
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={inputMessage}
|
||||
onChange={(e) => 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"
|
||||
/>
|
||||
<button
|
||||
onClick={handleSendMessage}
|
||||
className="px-6 py-3 bg-gradient-to-r from-blue-600 to-cyan-600 text-white rounded-lg font-medium hover:shadow-lg transition-all"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// Timeline View Component
|
||||
const TimelineView: React.FC<TimelineViewProps> = ({ files, messages }) => (
|
||||
<div className="space-y-4 animate-fadeIn">
|
||||
<h2 className="text-2xl font-bold text-white">📅 Activity Timeline</h2>
|
||||
<div className="space-y-3">
|
||||
{[...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) => (
|
||||
<div key={idx} className="flex gap-4 bg-slate-800/50 backdrop-blur-xl rounded-xl p-4 border border-slate-700">
|
||||
<div className="text-2xl">{'content' in item ? '💬' : '📄'}</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-white font-medium">
|
||||
{'content' in item ? `Message from ${item.senderName}` : `File uploaded: ${item.name}`}
|
||||
</p>
|
||||
<p className="text-sm text-slate-400">
|
||||
{new Date(item.timestamp || Date.now()).toLocaleString()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// Settings View Component
|
||||
const SettingsView: React.FC<SettingsViewProps> = ({ lawyer }) => (
|
||||
<div className="space-y-6 animate-fadeIn">
|
||||
<h2 className="text-2xl font-bold text-white">⚙️ Workspace Settings</h2>
|
||||
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-4">🔐 Privacy & Access Control</h3>
|
||||
<div className="space-y-4">
|
||||
{[
|
||||
{ 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) => (
|
||||
<div key={member.role} className="flex items-center justify-between p-4 bg-slate-900/50 rounded-lg">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-2xl">{member.icon}</span>
|
||||
<div>
|
||||
<p className="text-white font-medium">{member.role}</p>
|
||||
<p className="text-sm text-slate-400">{member.access}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-sm text-blue-400 hover:text-blue-300">Edit</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-4">🔔 Notifications</h3>
|
||||
<div className="space-y-3">
|
||||
{[
|
||||
{ label: 'Email notifications', enabled: true },
|
||||
{ label: 'Push notifications', enabled: true },
|
||||
{ label: 'SMS alerts', enabled: false }
|
||||
].map((setting) => (
|
||||
<div key={setting.label} className="flex items-center justify-between p-3 bg-slate-900/50 rounded-lg">
|
||||
<span className="text-white">{setting.label}</span>
|
||||
<div className={`w-12 h-6 rounded-full transition-colors ${setting.enabled ? 'bg-blue-600' : 'bg-slate-600'}`}>
|
||||
<div className={`w-5 h-5 bg-white rounded-full mt-0.5 transition-transform ${setting.enabled ? 'ml-6' : 'ml-0.5'}`} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// 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<string, string> = {
|
||||
'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;
|
||||
@@ -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';
|
||||
@@ -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<ChatViewProps> = ({
|
||||
messages,
|
||||
inputMessage,
|
||||
setInputMessage,
|
||||
handleSendMessage,
|
||||
isTyping,
|
||||
lawyer,
|
||||
}) => {
|
||||
return (
|
||||
<div className="h-full flex flex-col bg-slate-800/50 backdrop-blur-xl rounded-2xl border border-slate-700">
|
||||
<div className="px-6 py-4 border-b border-slate-700">
|
||||
<h2 className="text-xl font-bold text-white">💬 Live Chat</h2>
|
||||
<p className="text-sm text-slate-400">AI + {lawyer.username} • No appointments needed</p>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-auto p-6 space-y-4">
|
||||
{messages.map((msg) => (
|
||||
<div key={msg.id} className={`flex gap-3 ${msg.sender === 'user' ? 'justify-end' : ''}`}>
|
||||
{msg.sender !== 'user' && (
|
||||
<div className="w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center text-white flex-shrink-0">
|
||||
{msg.avatar}
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className={`max-w-md ${msg.sender === 'user' ? 'bg-blue-600' : 'bg-slate-700'} rounded-2xl px-4 py-3`}
|
||||
>
|
||||
<p className="text-xs text-slate-300 mb-1">{msg.senderName}</p>
|
||||
<p className="text-white text-sm">{msg.content}</p>
|
||||
<p className="text-xs text-slate-400 mt-1">{msg.timestamp.toLocaleTimeString()}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{isTyping && (
|
||||
<div className="flex gap-3">
|
||||
<div className="w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center">
|
||||
🤖
|
||||
</div>
|
||||
<div className="bg-slate-700 rounded-2xl px-4 py-3">
|
||||
<div className="flex gap-1">
|
||||
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce" />
|
||||
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce delay-100" />
|
||||
<span className="w-2 h-2 bg-slate-400 rounded-full animate-bounce delay-200" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="p-4 border-t border-slate-700">
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={inputMessage}
|
||||
onChange={(e) => 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"
|
||||
/>
|
||||
<button
|
||||
onClick={handleSendMessage}
|
||||
className="px-6 py-3 bg-gradient-to-r from-blue-600 to-cyan-600 text-white rounded-lg font-medium hover:shadow-lg transition-all"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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<FilesViewProps> = ({
|
||||
categoriesWithFiles,
|
||||
selectedFile,
|
||||
setSelectedFile,
|
||||
onFileDelete,
|
||||
onFileVisibilityChange,
|
||||
}) => {
|
||||
return (
|
||||
<div className="space-y-6 animate-fadeIn">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="text-2xl font-bold text-white">📁 File Management</h2>
|
||||
<button className="px-4 py-2 bg-gradient-to-r from-blue-600 to-cyan-600 text-white rounded-lg font-medium hover:shadow-lg transition-all">
|
||||
+ Upload Files
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{categoriesWithFiles.map((category) => (
|
||||
<div
|
||||
key={category.id}
|
||||
className="bg-slate-800/50 backdrop-blur-xl rounded-2xl border border-slate-700 overflow-hidden"
|
||||
>
|
||||
<div className="px-6 py-4 bg-slate-900/50 border-b border-slate-700">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-2xl">{category.icon}</span>
|
||||
<h3 className="text-lg font-bold text-white">{category.title}</h3>
|
||||
<span className="text-xs bg-slate-700 text-slate-300 px-2 py-1 rounded-full">
|
||||
{category.count} files
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4 space-y-2">
|
||||
{category.files.map((file: UploadedFile) => (
|
||||
<div
|
||||
key={file.id}
|
||||
className={`flex items-center gap-4 p-4 rounded-lg border transition-all ${
|
||||
selectedFile === file.id
|
||||
? 'bg-blue-600/20 border-blue-500'
|
||||
: 'bg-slate-900/30 border-slate-700 hover:border-slate-600'
|
||||
}`}
|
||||
>
|
||||
<div className="text-3xl">📄</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-white font-medium truncate">{file.name}</p>
|
||||
<div className="flex items-center gap-4 mt-1">
|
||||
<span className="text-xs text-slate-400">{formatFileSize(file.size)}</span>
|
||||
<select
|
||||
value={file.visibility || 'private'}
|
||||
onChange={(e) => onFileVisibilityChange(file.id, e.target.value)}
|
||||
className="text-xs bg-slate-700 text-white px-2 py-1 rounded border border-slate-600"
|
||||
>
|
||||
<option value="private">🔒 Private</option>
|
||||
<option value="lawyer">👨⚖️ Lawyer Only</option>
|
||||
<option value="team">👥 Team</option>
|
||||
<option value="public">🌐 Public</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={() => setSelectedFile(file.id)}
|
||||
className="p-2 hover:bg-slate-700 rounded-lg text-slate-400 hover:text-white transition-colors"
|
||||
>
|
||||
👁️
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onFileDelete(file.id)}
|
||||
className="p-2 hover:bg-red-600/20 rounded-lg text-slate-400 hover:text-red-400 transition-colors"
|
||||
>
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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<OverviewViewProps> = ({
|
||||
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 (
|
||||
<div className="space-y-6 animate-fadeIn">
|
||||
{/* Welcome banner */}
|
||||
<div className="bg-gradient-to-r from-blue-600 to-cyan-600 rounded-2xl p-6 text-white">
|
||||
<h2 className="text-2xl font-bold mb-2">Welcome to Your Data Room 🚀</h2>
|
||||
<p className="text-blue-100">
|
||||
Your secure collaborative workspace is ready. All files are encrypted end-to-end.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Case summary */}
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-3">📋 Case Summary</h3>
|
||||
<p className="text-slate-300 text-sm leading-relaxed">{caseDescription}</p>
|
||||
</div>
|
||||
|
||||
{/* Quick actions */}
|
||||
<div className="grid sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
{QUICK_ACTIONS.map((action) => (
|
||||
<button
|
||||
key={action.title}
|
||||
onClick={() => setViewMode(action.view)}
|
||||
className="bg-slate-800/50 backdrop-blur-xl rounded-xl p-6 border border-slate-700 hover:border-slate-600 transition-all hover:scale-105 group"
|
||||
>
|
||||
<div
|
||||
className={`text-4xl mb-3 bg-gradient-to-br ${action.color} bg-clip-text text-transparent`}
|
||||
>
|
||||
{action.icon}
|
||||
</div>
|
||||
<h4 className="text-white font-bold mb-1">{action.title}</h4>
|
||||
<p className="text-slate-400 text-sm">{getActionCount(action.view)}</p>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* File categories preview */}
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-4">📂 File Categories</h3>
|
||||
<div className="grid sm:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||
{categoriesWithFiles.map((cat) => (
|
||||
<div key={cat.id} className="bg-slate-900/50 rounded-lg p-4 border border-slate-700">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-2xl">{cat.icon}</span>
|
||||
<span className="text-xs bg-blue-600 text-white px-2 py-1 rounded-full">
|
||||
{cat.count}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-sm text-white font-medium">{cat.title}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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<SettingsViewProps> = ({ 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 (
|
||||
<div className="space-y-6 animate-fadeIn">
|
||||
<h2 className="text-2xl font-bold text-white">⚙️ Workspace Settings</h2>
|
||||
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-4">🔐 Privacy & Access Control</h3>
|
||||
<div className="space-y-4">
|
||||
{teamMembers.map((member) => (
|
||||
<div
|
||||
key={member.role}
|
||||
className="flex items-center justify-between p-4 bg-slate-900/50 rounded-lg"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-2xl">{member.icon}</span>
|
||||
<div>
|
||||
<p className="text-white font-medium">{member.role}</p>
|
||||
<p className="text-sm text-slate-400">{member.access}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-sm text-blue-400 hover:text-blue-300">Edit</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-slate-800/50 backdrop-blur-xl rounded-2xl p-6 border border-slate-700">
|
||||
<h3 className="text-lg font-bold text-white mb-4">🔔 Notifications</h3>
|
||||
<div className="space-y-3">
|
||||
{notificationSettings.map((setting) => (
|
||||
<div
|
||||
key={setting.label}
|
||||
className="flex items-center justify-between p-3 bg-slate-900/50 rounded-lg"
|
||||
>
|
||||
<span className="text-white">{setting.label}</span>
|
||||
<div
|
||||
className={`w-12 h-6 rounded-full transition-colors ${setting.enabled ? 'bg-blue-600' : 'bg-slate-600'}`}
|
||||
>
|
||||
<div
|
||||
className={`w-5 h-5 bg-white rounded-full mt-0.5 transition-transform ${setting.enabled ? 'ml-6' : 'ml-0.5'}`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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<TimelineViewProps> = ({ 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 (
|
||||
<div className="space-y-4 animate-fadeIn">
|
||||
<h2 className="text-2xl font-bold text-white">📅 Activity Timeline</h2>
|
||||
<div className="space-y-3">
|
||||
{timelineItems.map((item, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="flex gap-4 bg-slate-800/50 backdrop-blur-xl rounded-xl p-4 border border-slate-700"
|
||||
>
|
||||
<div className="text-2xl">{item.itemType === 'message' ? '💬' : '📄'}</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-white font-medium">
|
||||
{item.itemType === 'message'
|
||||
? `Message from ${(item as ChatMessage).senderName}`
|
||||
: `File uploaded: ${(item as UploadedFile).name}`}
|
||||
</p>
|
||||
<p className="text-sm text-slate-400">
|
||||
{new Date(item.timestamp || Date.now()).toLocaleString()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
import { type FC } from 'react';
|
||||
import { type LawyerProfile } from '../types';
|
||||
|
||||
interface WorkspaceHeaderProps {
|
||||
lawyer: LawyerProfile;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const WorkspaceHeader: FC<WorkspaceHeaderProps> = ({ lawyer, onClose }) => {
|
||||
return (
|
||||
<header className="relative border-b border-slate-700 bg-slate-900/50 backdrop-blur-xl">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center text-white font-bold text-xl shadow-lg">
|
||||
L
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="text-xl font-bold text-white">Lex Workspace</h1>
|
||||
<p className="text-xs text-slate-400">
|
||||
Private Data Room • End-to-End Encrypted
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
{/* Lawyer info */}
|
||||
<div className="hidden sm:flex items-center gap-3 px-4 py-2 bg-slate-800 rounded-lg border border-slate-700">
|
||||
<span className="text-2xl">{lawyer.avatar}</span>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-white">{lawyer.username}</p>
|
||||
<p className="text-xs text-green-400 flex items-center gap-1">
|
||||
<span className="w-2 h-2 rounded-full bg-green-400 animate-pulse" />
|
||||
Online
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Close button */}
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-2 hover:bg-slate-800 rounded-lg transition-colors text-slate-400 hover:text-white"
|
||||
title="Exit Workspace"
|
||||
>
|
||||
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
@@ -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<WorkspaceSidebarProps> = ({
|
||||
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 (
|
||||
<aside className="w-20 lg:w-64 bg-slate-900/50 backdrop-blur-xl border-r border-slate-700 flex flex-col">
|
||||
<nav className="flex-1 p-4 space-y-2">
|
||||
{NAV_ITEMS.map((item) => {
|
||||
const badge = item.hasBadge ? getBadgeCount(item.id) : undefined;
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
onClick={() => setViewMode(item.id)}
|
||||
className={`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-all ${
|
||||
viewMode === item.id
|
||||
? 'bg-gradient-to-r from-blue-600 to-cyan-600 text-white shadow-lg scale-105'
|
||||
: 'text-slate-400 hover:bg-slate-800 hover:text-white'
|
||||
}`}
|
||||
>
|
||||
<span className="text-xl">{item.icon}</span>
|
||||
<span className="hidden lg:block font-medium">{item.label}</span>
|
||||
{badge !== undefined && (
|
||||
<span className="hidden lg:block ml-auto bg-slate-700 text-white text-xs px-2 py-0.5 rounded-full">
|
||||
{badge}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* Quick Stats */}
|
||||
<div className="hidden lg:block p-4 border-t border-slate-700">
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-slate-400">Files</span>
|
||||
<span className="text-white font-bold">{files.length}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-slate-400">Messages</span>
|
||||
<span className="text-white font-bold">{messages.length}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-slate-400">Storage</span>
|
||||
<span className="text-white font-bold">{formatTotalSize(files)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
};
|
||||
@@ -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';
|
||||
@@ -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<string, string> = {
|
||||
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;
|
||||
}
|
||||
Reference in new issue
Block a user