diff --git a/app/components/TaskPanel.tsx b/app/components/TaskPanel.tsx index 4520fb5..b837b78 100644 --- a/app/components/TaskPanel.tsx +++ b/app/components/TaskPanel.tsx @@ -1,5 +1,22 @@ "use client"; +import React, { useEffect, useState } from 'react'; +import { DragDropContext, DropResult } from '@hello-pangea/dnd'; +import ExportMenu from './ExportMenu'; +import { TaskList as TaskListComponent } from './TaskList'; +import { ThemeProvider, useTheme, ThemeType } from '../hooks/useTheme'; +import { useTasks } from '../hooks/useTasks'; +import { useSearch } from '../hooks/useSearch'; +import SearchBar from './SearchBar'; +import { useKeyboardShortcuts } from '../hooks/useKeyboardShortcuts'; +import ThemeSelector from './ThemeSelector'; +import TaskForm from './TaskForm'; +import AIAssistantPanel from './AIAssistantPanel'; +import TaskAnalytics from './TaskAnalytics'; +import TaskAutomation from './TaskAutomation'; +import React, { useEffect, useState } from 'react'; +import { DragDropContext, DropResult } from '@hello-pangea/dnd'; +import ExportMenu from './ExportMenu'; import React, { useEffect, useState } from 'react'; import { DragDropContext, DropResult } from '@hello-pangea/dnd'; import ExportMenu from './ExportMenu'; @@ -21,6 +38,9 @@ import { useRouter } from 'next/navigation'; import { Task } from '../types/task'; import { colors } from '../config/colors'; import AGiXTConfig from './AGiXTConfig'; +import { WorkspacePanel } from './WorkspacePanel'; +import ViewSelector from './ViewSelector'; +import { ViewType } from '../types/view'; const defaultTheme: ThemeType = { primary: colors.primary.DEFAULT, @@ -40,7 +60,7 @@ const defaultTheme: ThemeType = { } }; -const TaskPanel: React.FC = () => { +const TaskPanel: React.FC = () =>{ const [mounted, setMounted] = useState(false); const [isInitialized, setIsInitialized] = useState(false); const [error, setError] = useState(null); @@ -53,12 +73,13 @@ const TaskPanel: React.FC = () => { const [isAGiXTConfigOpen, setIsAGiXTConfigOpen] = useState(false); const [selectedTask, setSelectedTask] = useState(null); const [agixtConfig, setAgixtConfig] = useState({ backendUrl: '', authToken: '' }); - + const [currentView, setCurrentView] = useState('board'); + const { tasks, addTask, updateTask, deleteTask, reorderTasks, lists } = useTasks({ remoteEnabled: false, userId: 'anonymous' }); - + const { searchTerm, setSearchTerm, @@ -101,14 +122,14 @@ useEffect(() =>{ }, [token, noAuth]); useKeyboardShortcuts({ - onNewTask: () => setIsEditorOpen(true), - onSearch: () => document.getElementById('search-input')?.focus(), - onToggleView: () => {}, - onDelete: () => {}, - onDeleteTask: () => {} + onNewTask: () =>setIsEditorOpen(true), + onSearch: () =>document.getElementById('search-input')?.focus(), + onToggleView: () =>{}, + onDelete: () =>{}, + onDeleteTask: () =>{} }); - const onDragEnd = (result: DropResult) => { + const onDragEnd = (result: DropResult) =>{ if (!result.destination) return; const sourceStatus = result.source.droppableId; @@ -116,13 +137,13 @@ useEffect(() =>{ const taskId = result.draggableId; if (sourceStatus === destinationStatus) { - const listTasks = tasks.filter(t => t.status === sourceStatus); + const listTasks = tasks.filter(t =>t.status === sourceStatus); const [movedTask] = listTasks.splice(result.source.index, 1); listTasks.splice(result.destination.index, 0, movedTask); - const updatedTasks = tasks.map(t => { + const updatedTasks = tasks.map(t =>{ if (t.status === sourceStatus) { - const reorderedTask = listTasks.find(rt => rt.id === t.id); + const reorderedTask = listTasks.find(rt =>rt.id === t.id); return reorderedTask || t; } return t; @@ -130,7 +151,7 @@ useEffect(() =>{ reorderTasks(updatedTasks); } else { - const task = tasks.find(t => t.id === taskId); + const task = tasks.find(t =>t.id === taskId); if (!task) return; const updatedTask = { @@ -142,7 +163,7 @@ useEffect(() =>{ } }; - const handleTaskSuggestion = (taskSuggestion: Partial) => { + const handleTaskSuggestion = (taskSuggestion: Partial) =>{ const newTask: Task = { id: Date.now().toString(), title: taskSuggestion.title || '', @@ -162,18 +183,164 @@ useEffect(() =>{ addTask(newTask); }; - const handleTaskOptimization = (taskIds: string[]) => { - const optimizedTasks = taskIds.map(id => tasks.find(t => t.id === id)).filter(Boolean) as Task[]; + const handleTaskOptimization = (taskIds: string[]) =>{ + const optimizedTasks = taskIds.map(id =>tasks.find(t =>t.id === id)).filter(Boolean) as Task[]; reorderTasks(optimizedTasks); }; if (!mounted || !isInitialized) { - return ( -
-
-
Loading Task Panel...
-
Please wait while we set things up
-
+ return (
Loading Task Panel...
Please wait while we set things up
); + } + + if (error) { + return (
Error Loading Task Panel
{error}
); + } + + return (

Task Panel

{isAGiXTConfigOpen && (
setIsAGiXTConfigOpen(false)} + onSave={(config) =>{ + setAgixtConfig(config); + setIsAGiXTConfigOpen(false); + }} + />
)}

To Do

task.status === 'todo')} + onUpdateTask={updateTask} + onTaskClick={(task) =>setSelectedTask(task)} + onDeleteTask={(task) =>deleteTask(task.id)} + onReorderTasks={reorderTasks} + listId="default" + />

In Progress

task.status === 'in-progress')} + onUpdateTask={updateTask} + onTaskClick={(task) =>setSelectedTask(task)} + onDeleteTask={(task) =>deleteTask(task.id)} + onReorderTasks={reorderTasks} + listId="default" + />

Done

task.status === 'done')} + onUpdateTask={updateTask} + onTaskClick={(task) =>setSelectedTask(task)} + onDeleteTask={(task) =>deleteTask(task.id)} + onReorderTasks={reorderTasks} + listId="default" + />
{isEditorOpen && (
{ + addTask(task); + setIsEditorOpen(false); + }} + onCancel={() =>setIsEditorOpen(false)} + lists={lists} + />
)}
{agixtConfig.backendUrl && agixtConfig.authToken && ()}{selectedTask && (setSelectedTask(null)} + onUpdateTask={updateTask} + allTasks={tasks} + className="ml-4 mt-4" + />)}
); +}; + +export default TaskPanel; + } + + return (

Task Panel

{isAGiXTConfigOpen && (
setIsAGiXTConfigOpen(false)} + onSave={(config) =>{ + setAgixtConfig(config); + setIsAGiXTConfigOpen(false); + }} + />
)}

To Do

task.status === 'todo')} + onUpdateTask={updateTask} + onTaskClick={(task) =>setSelectedTask(task)} + onDeleteTask={(task) =>deleteTask(task.id)} + onReorderTasks={reorderTasks} + listId="default" + />

In Progress

task.status === 'in-progress')} + onUpdateTask={updateTask} + onTaskClick={(task) =>setSelectedTask(task)} + onDeleteTask={(task) =>deleteTask(task.id)} + onReorderTasks={reorderTasks} + listId="default" + />

Done

task.status === 'done')} + onUpdateTask={updateTask} + onTaskClick={(task) =>setSelectedTask(task)} + onDeleteTask={(task) =>deleteTask(task.id)} + onReorderTasks={reorderTasks} + listId="default" + />
{isEditorOpen && (
{ + addTask(task); + setIsEditorOpen(false); + }} + onCancel={() =>setIsEditorOpen(false)} + lists={lists} + />
)}
{agixtConfig.backendUrl && agixtConfig.authToken && ()} + {selectedTask && (setSelectedTask(null)} + onUpdateTask={updateTask} + allTasks={tasks} + className="ml-4 mt-4" + />)}
); +}; + +export default TaskPanel;
); }