import React, { useState, useEffect } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog'; import { Button } from './ui/button'; import { Input } from './ui/input'; import { Textarea } from './ui/textarea'; import { Label } from './ui/label'; import { useApp } from '../contexts/AppContext'; import { Task } from '../types'; import { Trash2 } from 'lucide-react'; interface EditTaskDialogProps { open: boolean; onOpenChange: (open: boolean) => void; task: Task | null; } export const EditTaskDialog: React.FC = ({ open, onOpenChange, task }) => { const { updateTask, deleteTask } = useApp(); const [title, setTitle] = useState(''); const [description, setDescription] = useState(''); const [timeComplexity, setTimeComplexity] = useState(''); useEffect(() => { if (task) { setTitle(task.title); setDescription(task.description); setTimeComplexity(task.timeComplexity); } }, [task]); const handleSave = () => { if (task && title.trim()) { updateTask(task.id, { title, description, timeComplexity }); onOpenChange(false); } }; const handleDelete = () => { if (task && confirm('Are you sure you want to delete this task?')) { deleteTask(task.id); onOpenChange(false); } }; return ( Edit Task
setTitle(e.target.value)} placeholder="Enter task title" />