import { useQuery } from '@tanstack/react-query' import { client } from '@/ui/api/client' import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/ui/components/ui/dialog' import { m } from '@/ui/paraglide/messages.js' import { Loader2, Bot } from 'lucide-react' import type { KanbanTaskDetail } from '@shumai/dtos' import { cn } from '@/ui/lib/utils' import { getStatusBadgeColor, getStatusLabel } from '../kanban-types' import { TaskInfoForm } from './task-info-form' import { TaskActivityPane } from './task-activity-pane' interface EditTaskDialogProps { teamId: string taskId: string | null isOpen: boolean onClose: () => void canEdit?: boolean } export function EditTaskDialog({ teamId, taskId, isOpen, onClose, canEdit = true, }: EditTaskDialogProps) { const { data: task, isLoading, error, } = useQuery({ queryKey: ['teams', teamId, 'kanban', 'task', taskId], queryFn: async () => { if (!taskId) return null const res = await client.api.teams[':teamId'].kanban.tasks[':taskId'].$get({ param: { teamId, taskId }, }) if (!res.ok) throw new Error('Failed to fetch task details') return (await res.json()) as KanbanTaskDetail }, enabled: !!teamId && !!taskId && isOpen, }) return ( !open && onClose()}>
{task?.isAgentTask && ( {m.task_type_agent()} )} {task?.status && ( {getStatusLabel(task.status)} )} {task?.title || m.edit_task()}
{/* 2-Columns Body: Left 2/3, Right 1/3 */}
{isLoading ? (
) : error || !task ? (
{m.file_not_found()}
) : ( <> {/* Left Column (2/3 width) */}
{/* Right Column (1/3 width) */}
)}
) }