import React, { useEffect, useState } from 'react'; import { Layers, CheckSquare, FileText, ShoppingCart, Webhook, Brain, LogOut, User as UserIcon, Sparkles, } from 'lucide-react'; import { DashboardStats, SharedList, Thought, User } from './lib/types'; import { api, clearToken, getToken } from './lib/api'; import { InstantCaptureBar } from './features/capture/InstantCaptureBar'; import { TriageDeck } from './features/triage/TriageDeck'; import { TasksView } from './features/triage/TasksView'; import { WorkspaceView } from './features/workspace/WorkspaceView'; import { SharedListsView } from './features/lists/SharedListsView'; import { EcosystemView } from './features/settings/EcosystemView'; type ActiveTab = 'triage' | 'tasks' | 'workspace' | 'lists' | 'ecosystem'; export const App: React.FC = () => { const [user, setUser] = useState(null); const [stats, setStats] = useState({ inboxCount: 0, tasksOpenCount: 0, tasksDoneCount: 0, docsCount: 0, listsCount: 0, discardedCount: 0, }); const [deck, setDeck] = useState([]); const [lists, setLists] = useState([]); const [activeTab, setActiveTab] = useState('triage'); const [selectedDocId, setSelectedDocId] = useState(null); const [captureFocusCount, setCaptureFocusCount] = useState(0); // Auth Modal State for switching or registering additional family members const [showAuthModal, setShowAuthModal] = useState(false); const [authMode, setAuthMode] = useState<'login' | 'register'>('login'); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [displayName, setDisplayName] = useState(''); const [authError, setAuthError] = useState(''); const refreshAll = async () => { try { const [meRes, deckRes, listsRes] = await Promise.all([ api.getMe(), api.getTriageDeck(), api.getAllLists(), ]); setUser(meRes.user); setStats(meRes.stats); setDeck(deckRes); setLists(listsRes); } catch { // Fallback to quickStart session try { const qs = await api.quickStart(); setUser(qs.user); const [st, dk, ls] = await Promise.all([ api.getStats(), api.getTriageDeck(), api.getAllLists(), ]); setStats(st); setDeck(dk); setLists(ls); } catch { // Offline or waiting for server } } }; useEffect(() => { const init = async () => { if (!getToken()) { try { await api.quickStart(); } catch { // ignore } } await api.flushOfflineQueue(); await refreshAll(); }; init(); const onOnline = async () => { const synced = await api.flushOfflineQueue(); if (synced > 0) refreshAll(); }; window.addEventListener('online', onOnline); return () => window.removeEventListener('online', onOnline); }, []); const handleCaptured = (thought: Thought) => { setDeck((prev) => [thought, ...prev]); setStats((prev) => ({ ...prev, inboxCount: prev.inboxCount + 1 })); refreshAll(); }; const handleOpenDocument = (docId: string) => { setSelectedDocId(docId); setActiveTab('workspace'); }; const handleAuthSubmit = async (e: React.FormEvent) => { e.preventDefault(); setAuthError(''); try { if (authMode === 'login') { await api.login(email, password); } else { await api.register(email, password, displayName); } setShowAuthModal(false); setEmail(''); setPassword(''); setDisplayName(''); await refreshAll(); } catch (err: any) { setAuthError(err.message || 'Authentifizierung fehlgeschlagen'); } }; return (
{/* Ambient Top Gemini Glow */}
{/* Header Bar */}
{/* Brand Logo */}
{ setActiveTab('triage'); setCaptureFocusCount((c) => c + 1); }} className="flex items-center gap-2.5 cursor-pointer group" >
MindSift Der Kopf frei in drei Sekunden.
{/* Right User Pill */}
{/* Main Content Container */}
{/* Global Instant Capture Section (Always Ready at Top) */}
{/* Pill Navigation Tabs */} {/* Active View Content */}
{activeTab === 'triage' && ( setCaptureFocusCount((c) => c + 1)} /> )} {activeTab === 'tasks' && ( )} {activeTab === 'workspace' && ( )} {activeTab === 'lists' && ( )} {activeTab === 'ecosystem' && ( )}
{/* Account Switcher / Registration Modal */} {showAuthModal && (

{authMode === 'login' ? 'Konto wechseln' : 'Neues Familien-Konto anlegen'}

{user && (
Aktuell aktiv: {user.displayName} ({user.email})
)}
{authMode === 'register' && ( setDisplayName(e.target.value)} placeholder="Anzeigename (z. B. Lisa)" className="w-full h-11 px-4 rounded-full bg-[#131314] text-sm text-[#e3e3e3] gemini-border focus:outline-none" required /> )} setEmail(e.target.value)} placeholder="E-Mail-Adresse" className="w-full h-11 px-4 rounded-full bg-[#131314] text-sm text-[#e3e3e3] gemini-border focus:outline-none" required /> setPassword(e.target.value)} placeholder="Passwort (mind. 4 Zeichen)" className="w-full h-11 px-4 rounded-full bg-[#131314] text-sm text-[#e3e3e3] gemini-border focus:outline-none" required /> {authError &&

{authError}

}
)}
); }; export default App;