diff --git a/apps/web/app/components/EditTaskForm.tsx b/apps/web/app/components/EditTaskForm.tsx new file mode 100644 index 000000000..69a913ccd --- /dev/null +++ b/apps/web/app/components/EditTaskForm.tsx @@ -0,0 +1,160 @@ +'use client'; + +import { useState, useEffect } from 'react'; +import { useRouter } from 'next/navigation'; + +const API_BASE = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'; + +interface EditTaskFormProps { + taskId: string; + initialData: { + name: string; + description: string; + priority: string; + assignee_user_id: string; + }; + onSuccess?: () => void; + onCancel?: () => void; +} + +export default function EditTaskForm({ taskId, initialData, onSuccess, onCancel }: EditTaskFormProps) { + const router = useRouter(); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + const [formData, setFormData] = useState(initialData); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setLoading(true); + setError(''); + + try { + // 注意:这里需要后端补充 PATCH /tasks/{id} 接口 + alert('任务编辑功能需要后端补充 PATCH /tasks/{id} 接口'); + if (onSuccess) onSuccess(); + } catch (err: any) { + setError(err.message); + } finally { + setLoading(false); + } + }; + + return ( +
+

编辑任务

+ + {error && ( +
+ {error} +
+ )} + +
+ + setFormData({ ...formData, name: e.target.value })} + style={{ + width: '100%', + padding: '8px 12px', + border: '1px solid var(--border)', + borderRadius: '4px', + fontSize: '14px', + }} + /> +
+ +
+ +