forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskListView.tsx
More file actions
168 lines (157 loc) · 5.49 KB
/
Copy pathTaskListView.tsx
File metadata and controls
168 lines (157 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
'use client';
import { motion, AnimatePresence } from 'framer-motion';
import { ChevronDown, ChevronUp } from 'lucide-react';
import { cn } from '@/lib/utils';
import { TaskRow } from './TaskRow';
import type { ActionItem } from '@/types/conversation';
interface TaskListViewProps {
pendingTasks: ActionItem[];
completedTasks: ActionItem[];
showCompleted: boolean;
onToggleShowCompleted: () => void;
selectedIds: Set<string>;
onSelect: (id: string, selected: boolean) => void;
isSelectMode: boolean;
focusedIndex: number;
onToggleComplete: (id: string, completed: boolean) => void;
onSnooze: (id: string, days: number) => void;
onDelete: (id: string) => void;
onUpdateDescription: (id: string, description: string) => void;
onSetDueDate: (id: string, date: Date | null) => void;
searchQuery?: string;
// Double-click to enter selection mode
onEnterSelectionMode?: (id: string) => void;
}
export function TaskListView({
pendingTasks,
completedTasks,
showCompleted,
onToggleShowCompleted,
selectedIds,
onSelect,
isSelectMode,
focusedIndex,
onToggleComplete,
onSnooze,
onDelete,
onUpdateDescription,
onSetDueDate,
searchQuery = '',
onEnterSelectionMode,
}: TaskListViewProps) {
// Filter tasks based on search query
const filteredPending = searchQuery
? pendingTasks.filter((t) =>
t.description.toLowerCase().includes(searchQuery.toLowerCase()),
)
: pendingTasks;
const filteredCompleted = searchQuery
? completedTasks.filter((t) =>
t.description.toLowerCase().includes(searchQuery.toLowerCase()),
)
: completedTasks;
const isEmpty = filteredPending.length === 0 && filteredCompleted.length === 0;
if (isEmpty && !searchQuery) {
return (
<div className="flex flex-col items-center justify-center py-16 text-center">
<div className="w-16 h-16 mb-4 rounded-full bg-bg-tertiary flex items-center justify-center">
<span className="text-2xl">✓</span>
</div>
<h3 className="text-lg font-medium text-text-primary mb-2">All caught up!</h3>
<p className="text-sm text-text-tertiary">
No tasks to show. Add a new task to get started.
</p>
</div>
);
}
if (isEmpty && searchQuery) {
return (
<div className="flex flex-col items-center justify-center py-16 text-center">
<p className="text-sm text-text-tertiary">
No tasks match "{searchQuery}"
</p>
</div>
);
}
return (
<div className="flex flex-col">
{/* Pending tasks - flat list */}
<div className="border border-bg-tertiary rounded-lg">
<AnimatePresence mode="popLayout">
{filteredPending.map((task, index) => (
<TaskRow
key={task.id}
task={task}
onToggleComplete={onToggleComplete}
onSnooze={onSnooze}
onDelete={onDelete}
onUpdateDescription={onUpdateDescription}
onSetDueDate={onSetDueDate}
isSelected={selectedIds.has(task.id)}
onSelect={isSelectMode ? onSelect : undefined}
isFocused={focusedIndex === index}
onEnterSelectionMode={onEnterSelectionMode}
/>
))}
</AnimatePresence>
{filteredPending.length === 0 && (
<div className="px-4 py-8 text-center text-text-tertiary text-sm">
No pending tasks
</div>
)}
</div>
{/* Completed tasks toggle */}
{filteredCompleted.length > 0 && (
<div className="mt-4">
<button
onClick={onToggleShowCompleted}
className={cn(
'flex items-center gap-2 px-3 py-2 w-full',
'text-sm text-text-tertiary hover:text-text-secondary',
'transition-colors rounded-lg hover:bg-bg-tertiary/50',
)}
>
{showCompleted ? (
<ChevronUp className="w-4 h-4" />
) : (
<ChevronDown className="w-4 h-4" />
)}
<span>
{showCompleted ? 'Hide' : 'Show'} {filteredCompleted.length} completed task
{filteredCompleted.length !== 1 ? 's' : ''}
</span>
</button>
<AnimatePresence>
{showCompleted && (
<motion.div
initial={{ height: 0, opacity: 0 }}
animate={{ height: 'auto', opacity: 1 }}
exit={{ height: 0, opacity: 0 }}
transition={{ duration: 0.2 }}
className="overflow-hidden"
>
<div className="border border-bg-tertiary rounded-lg overflow-hidden mt-2">
{filteredCompleted.map((task, index) => (
<TaskRow
key={task.id}
task={task}
onToggleComplete={onToggleComplete}
onSnooze={onSnooze}
onDelete={onDelete}
onUpdateDescription={onUpdateDescription}
onSetDueDate={onSetDueDate}
isSelected={selectedIds.has(task.id)}
onSelect={isSelectMode ? onSelect : undefined}
isFocused={focusedIndex === filteredPending.length + index}
onEnterSelectionMode={onEnterSelectionMode}
/>
))}
</div>
</motion.div>
)}
</AnimatePresence>
</div>
)}
</div>
);
}