import { useEffect, useState } from 'react'; import { Search, ArrowDownToLine, Package, Grid3X3, Clock, ChevronRight, } from 'lucide-react'; import { useTheme } from '../lib/theme'; import { api } from '../lib/api'; import type { Page, UpdatePackage } from '../types'; interface DashboardProps { onNavigate: (page: Page) => void; onSelectPackage: (name: string) => void; } export default function Dashboard({ onNavigate, onSelectPackage }: DashboardProps) { const { theme } = useTheme(); const isDark = theme === 'dark'; const [updates, setUpdates] = useState([]); const [quickSearch, setQuickSearch] = useState(''); const [loading, setLoading] = useState(true); useEffect(() => { api.checkUpdates() .then(data => setUpdates(data.results)) .catch(() => {}) .finally(() => setLoading(false)); }, []); const panelClass = `border rounded-sm ${ isDark ? 'bg-dark-panel border-dark-border' : 'bg-light-panel border-light-border' }`; const sectionTitle = `text-lg font-medium mb-2 ${isDark ? 'text-dark-text' : 'text-light-text'}`; const secondaryText = isDark ? 'text-dark-text-secondary' : 'text-light-text-secondary'; const popularPackages = [ { name: 'firefox', desc: 'Standalone web browser from Mozilla', repo: 'extra' }, { name: 'vim', desc: 'Highly configurable text editor', repo: 'extra' }, { name: 'git', desc: 'Distributed version control system', repo: 'extra' }, { name: 'htop', desc: 'Interactive process viewer', repo: 'extra' }, { name: 'neovim', desc: 'Vim-fork focused on extensibility', repo: 'extra' }, { name: 'docker', desc: 'Container runtime environment', repo: 'extra' }, { name: 'nodejs', desc: 'Evented I/O for V8 javascript', repo: 'extra' }, { name: 'python', desc: 'High-level programming language', repo: 'extra' }, ]; const categories = [ { name: 'Development', icon: '⌨' }, { name: 'System', icon: '⚙' }, { name: 'Network', icon: '🌐' }, { name: 'Multimedia', icon: '🎵' }, { name: 'Games', icon: '🎮' }, { name: 'Desktop', icon: '🖥' }, ]; const recentActivity = [ { action: 'Installed', pkg: 'neovim', time: '2 hours ago' }, { action: 'Updated', pkg: 'firefox', time: '5 hours ago' }, { action: 'Removed', pkg: 'nano', time: '1 day ago' }, { action: 'Installed', pkg: 'ripgrep', time: '2 days ago' }, { action: 'Updated', pkg: 'linux', time: '3 days ago' }, ]; return (

Dashboard

{/* Quick search */}

Search Packages

setQuickSearch(e.target.value)} onKeyDown={e => { if (e.key === 'Enter' && quickSearch.trim()) { onNavigate('search'); } }} className={`w-full pl-8 pr-3 py-1.5 text-sm border rounded-sm ${ isDark ? 'bg-dark-bg border-dark-border text-dark-text placeholder:text-dark-text-secondary' : 'bg-light-bg border-light-border text-light-text placeholder:text-light-text-secondary' }`} />
{/* Updates available */}

Updates Available

{loading ? (

Checking for updates...

) : updates.length === 0 ? (

System is up to date.

) : ( {updates.slice(0, 5).map(u => ( ))}
Package Current New Source
onSelectPackage(u.name)}> {u.name} {u.current_version} {u.new_version} {u.source}
)} {updates.length > 5 && (

and {updates.length - 5} more...

)}
{/* Recent activity */}

Recent Activity

{recentActivity.map((a, i) => ( ))}
Action Package Time
{a.action} onSelectPackage(a.pkg)}> {a.pkg} {a.time}
{/* Popular packages */}

Popular Packages

{popularPackages.map(pkg => ( onSelectPackage(pkg.name)} > ))}
Name Description Repository
{pkg.name} {pkg.desc} {pkg.repo}
{/* Categories */}

Categories

{categories.map(cat => ( ))}
); }