import { useState, type ReactElement } from 'react'; import { KanbanBoard } from '@/components/tasks/kanban-board'; import { TaskDetailModal } from '@/components/tasks/task-detail-modal'; import { TaskListView } from '@/components/tasks/task-list-view'; import { StaleDataNotice, UnavailableDataNotice } from '@/components/freshness/freshness-notices'; import { api } from '@/lib/api'; import { cn } from '@/lib/cn'; import type { Task } from '@/lib/types'; import { useFreshCollection, describeFailure } from '@/lib/freshness/use-fresh-collection'; import { validateTaskCollection } from '@/lib/freshness/validators'; type ViewMode = 'list' | 'kanban'; export function TasksPage(): ReactElement { const tasks = useFreshCollection({ source: 'gateway:/api/tasks', fetcher: (signal) => api('/api/tasks', { signal }), validate: validateTaskCollection, cacheKey: 'tasks', }); const [view, setView] = useState('kanban'); const [selectedTask, setSelectedTask] = useState(null); const retry = (): void => { void tasks.revalidate(); }; return (

Tasks

{tasks.freshness === 'stale' && tasks.snapshot ? (
) : null} {tasks.freshness === 'unknown' ? (

Loading tasks...

) : tasks.freshness === 'unavailable' ? ( ) : view === 'kanban' ? ( ) : ( )} {selectedTask ? ( setSelectedTask(null)} /> ) : null}
); }