/* @component-map * App — Main container, handles layout and view composition * StatsBar — Displays remaining, high priority, and completed task counts * AddTaskForm — Form for adding new farm tasks * FilterBar — Area filter buttons * TaskList — Renders to-do and completed task sections * TaskItem — Individual task row with check, details, and delete * SyncBar — Real-time sync status indicator * @end-component-map */ import { useCollection, useAuth } from '@deplixo/sdk'; import { StatsBar } from './components/StatsBar.jsx'; import { AddTaskForm } from './components/AddTaskForm.jsx'; import { FilterBar } from './components/FilterBar.jsx'; import { TaskList } from './components/TaskList.jsx'; import { SyncBar } from './components/SyncBar.jsx'; function App() { const { user, login, logout, loading: authLoading } = useAuth(); const { items, loading, add, update, remove } = useCollection('tasks'); const [filterArea, setFilterArea] = React.useState('all'); const sorted = React.useMemo(() => [...items].sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0)), [items] ); const filtered = React.useMemo(() => filterArea === 'all' ? sorted : sorted.filter(t => t.area === filterArea), [sorted, filterArea] ); const todo = React.useMemo(() => filtered.filter(t => !t.done), [filtered]); const done = React.useMemo(() => filtered.filter(t => t.done), [filtered]); const totalRemaining = React.useMemo(() => sorted.filter(t => !t.done).length, [sorted]); const totalHigh = React.useMemo(() => sorted.filter(t => !t.done && t.priority === 'high').length, [sorted]); const totalDone = React.useMemo(() => sorted.filter(t => t.done).length, [sorted]); const handleAdd = async (task) => { await add({ ...task, done: false, createdAt: Date.now() }); }; const handleToggle = async (task) => { await update(task.id, { done: !task.done }); }; const handleDelete = async (task) => { await remove(task.id); }; if (authLoading) { return (