forked from Gerome-Elassaad/CodingIT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask-page-client.tsx
More file actions
208 lines (189 loc) · 6.86 KB
/
Copy pathtask-page-client.tsx
File metadata and controls
208 lines (189 loc) · 6.86 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
'use client'
import { useState } from 'react'
import { useTask } from '@/hooks/use-task'
import { TaskDetails } from '@/components/task-details'
import { TaskPageHeader } from '@/components/task-page-header'
import { Card, CardContent } from '@/components/ui/card'
import { Button } from '@/components/ui/button'
import { ListTodo, X } from 'lucide-react'
import { cn } from '@/lib/utils'
interface TaskPageClientProps {
taskId: string
}
export function TaskPageClient({ taskId }: TaskPageClientProps) {
const { task, isLoading, error } = useTask(taskId)
const [isSidebarOpen, setIsSidebarOpen] = useState(false)
if (isLoading) {
return (
<div className="flex h-screen bg-background">
{/* Main content */}
<div className="flex-1 relative">
{/* Task toggle button */}
<Button
variant="outline"
size="icon"
className="fixed top-4 right-4 z-50"
onClick={() => setIsSidebarOpen(!isSidebarOpen)}
>
<ListTodo className="h-4 w-4" />
</Button>
<div className="mx-auto p-3">
<div className="max-w-4xl mx-auto">
<div className="flex-1 p-6 overflow-y-auto">
<div className="max-w-4xl mx-auto space-y-6">
{/* Task Info Skeleton - 339px height */}
<Card className="h-[339px]">
<CardContent className="space-y-4"></CardContent>
</Card>
{/* Logs Skeleton - 512px height */}
<Card className="h-[512px]">
<CardContent></CardContent>
</Card>
</div>
</div>
</div>
</div>
</div>
{/* Right sidebar */}
<div className={cn(
"fixed top-0 right-0 h-full w-80 bg-background border-l shadow-lg transform transition-transform duration-300 ease-in-out z-40",
isSidebarOpen ? "translate-x-0" : "translate-x-full"
)}>
<div className="flex items-center justify-between p-4 border-b">
<h2 className="text-lg font-semibold">Task Details</h2>
<Button
variant="ghost"
size="icon"
onClick={() => setIsSidebarOpen(false)}
>
<X className="h-4 w-4" />
</Button>
</div>
<div className="p-4">
<div className="text-sm text-muted-foreground">Loading task details...</div>
</div>
</div>
</div>
)
}
if (error || !task) {
return (
<div className="flex h-screen bg-background">
{/* Main content */}
<div className="flex-1 relative">
{/* Task toggle button */}
<Button
variant="outline"
size="icon"
className="fixed top-4 right-4 z-50"
onClick={() => setIsSidebarOpen(!isSidebarOpen)}
>
<ListTodo className="h-4 w-4" />
</Button>
<div className="mx-auto p-3">
<div className="flex items-center justify-center h-64">
<div className="text-center">
<h2 className="text-lg font-semibold mb-2">Task Not Found</h2>
<p className="text-muted-foreground">{error || 'The requested task could not be found.'}</p>
</div>
</div>
</div>
</div>
{/* Right sidebar */}
<div className={cn(
"fixed top-0 right-0 h-full w-80 bg-background border-l shadow-lg transform transition-transform duration-300 ease-in-out z-40",
isSidebarOpen ? "translate-x-0" : "translate-x-full"
)}>
<div className="flex items-center justify-between p-4 border-b">
<h2 className="text-lg font-semibold">Task Details</h2>
<Button
variant="ghost"
size="icon"
onClick={() => setIsSidebarOpen(false)}
>
<X className="h-4 w-4" />
</Button>
</div>
<div className="p-4">
<div className="text-sm text-muted-foreground">No task data available</div>
</div>
</div>
</div>
)
}
return (
<div className="flex h-screen bg-background">
{/* Main content */}
<div className="flex-1 relative">
{/* Task toggle button */}
<Button
variant="outline"
size="icon"
className="fixed top-4 right-4 z-50"
onClick={() => setIsSidebarOpen(!isSidebarOpen)}
>
<ListTodo className="h-4 w-4" />
</Button>
<div className="mx-auto p-3 overflow-y-auto h-full">
<TaskPageHeader task={task} />
{/* Task details */}
<div className="max-w-4xl mx-auto">
<TaskDetails task={task} />
</div>
</div>
</div>
{/* Right sidebar */}
<div className={cn(
"fixed top-0 right-0 h-full w-80 bg-background border-l shadow-lg transform transition-transform duration-300 ease-in-out z-40",
isSidebarOpen ? "translate-x-0" : "translate-x-full"
)}>
<div className="flex items-center justify-between p-4 border-b">
<h2 className="text-lg font-semibold">Task Details</h2>
<Button
variant="ghost"
size="icon"
onClick={() => setIsSidebarOpen(false)}
>
<X className="h-4 w-4" />
</Button>
</div>
<div className="p-4 overflow-y-auto">
{task && (
<div className="space-y-4">
<div>
<h3 className="font-medium mb-2">Task ID</h3>
<p className="text-sm text-muted-foreground font-mono">{task.id}</p>
</div>
<div>
<h3 className="font-medium mb-2">Status</h3>
<p className="text-sm text-muted-foreground">{task.status}</p>
</div>
<div>
<h3 className="font-medium mb-2">Created</h3>
<p className="text-sm text-muted-foreground">
{new Date(task.created_at).toLocaleString()}
</p>
</div>
{task.prompt && (
<div>
<h3 className="font-medium mb-2">Prompt</h3>
<p className="text-sm text-muted-foreground">{task.prompt}</p>
</div>
)}
<div>
<h3 className="font-medium mb-2">Progress</h3>
<p className="text-sm text-muted-foreground">{task.progress}%</p>
</div>
{task.selected_model && (
<div>
<h3 className="font-medium mb-2">Model</h3>
<p className="text-sm text-muted-foreground">{task.selected_model}</p>
</div>
)}
</div>
)}
</div>
</div>
</div>
)
}