import { useState } from 'react' import { Flag } from 'lucide-react' const FLAG_COLORS = [ { name: null, label: 'None', color: 'bg-gray-700' }, { name: 'red', label: 'Red', color: 'bg-red-500' }, { name: 'orange', label: 'Orange', color: 'bg-orange-500' }, { name: 'yellow', label: 'Yellow', color: 'bg-yellow-500' }, { name: 'green', label: 'Green', color: 'bg-green-500' }, { name: 'blue', label: 'Blue', color: 'bg-blue-500' }, { name: 'purple', label: 'Purple', color: 'bg-purple-500' }, { name: 'pink', label: 'Pink', color: 'bg-pink-500' } ] // Helper to format status label const formatStatusLabel = (status) => { return status.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ') } function TaskForm({ onSubmit, onCancel, submitLabel = "Add", projectStatuses = null, defaultStatus = "backlog" }) { const [title, setTitle] = useState('') const [description, setDescription] = useState('') const [tags, setTags] = useState('') const [hours, setHours] = useState('') const [minutes, setMinutes] = useState('') const [flagColor, setFlagColor] = useState(null) const [status, setStatus] = useState(defaultStatus) // Use provided statuses or fall back to defaults const statuses = projectStatuses || ['backlog', 'in_progress', 'on_hold', 'done'] const handleSubmit = (e) => { e.preventDefault() if (!title.trim()) return // Convert hours and minutes to total minutes const totalMinutes = (parseInt(hours) || 0) * 60 + (parseInt(minutes) || 0) // Parse tags const tagList = tags ? tags.split(',').map(t => t.trim()).filter(t => t.length > 0) : null const taskData = { title: title.trim(), description: description.trim() || null, tags: tagList && tagList.length > 0 ? tagList : null, estimated_minutes: totalMinutes > 0 ? totalMinutes : null, flag_color: flagColor, status: status } onSubmit(taskData) } return (
{/* Title */}
setTitle(e.target.value)} placeholder="Enter task title..." className="w-full px-3 py-2 bg-cyber-darker border border-cyber-orange/50 rounded text-gray-100 text-sm focus:outline-none focus:border-cyber-orange" autoFocus />
{/* Description */}