import { useState } from 'react' import { Flag, ListPlus, Plus, User } from 'lucide-react' import { useTranslation } from '../../i18n' import { avatarSrc } from '../../utils/avatarSrc' import CustomSelect from '../shared/CustomSelect' import { CustomDatePicker } from '../shared/CustomDateTimePicker' import NameDialog from '../shared/NameDialog' import { Tooltip } from '../shared/Tooltip' import { GRID_2, LABEL, TEXTAREA } from '../shared/dialogParts' import { PRIO_CONFIG, katColor, taskInputStyle, taskLabelClass, type Member, type TaskFieldValues } from './todoListModel' interface TodoTaskFieldsProps { values: TaskFieldValues onChange: (patch: Partial) => void categories: string[] members: Member[] canEdit?: boolean /** 'dialog' draws the fields like the planner's dialogs: small caps labels, list and due date side by side. */ variant?: 'pane' | 'dialog' } /** * The fields a task is made of, shared by the detail pane and the new-task * dialog so both read and behave the same: description, priority as one * segmented track, the list (a new one is named in a dialog), the due date and * who does it. */ export default function TodoTaskFields({ values, onChange, categories, members, canEdit = true, variant = 'pane' }: TodoTaskFieldsProps) { const { t } = useTranslation() const [namingList, setNamingList] = useState(false) const [listName, setListName] = useState('') const { desc, priority, category, dueDate, assignedUserId } = values const dialog = variant === 'dialog' const labelClass = dialog ? LABEL : taskLabelClass const confirmList = () => { const name = listName.trim() if (!name) return onChange({ category: name }) setNamingList(false) setListName('') } const listField = (
onChange({ category: String(v) })} options={[ { value: '', label: t('todo.noCategory') }, ...categories.map(c => ({ value: c, label: c, icon: , })), ...(category && !categories.includes(category) ? [{ value: category, label: `${category} (${t('todo.newCategoryLabel')})`, icon: , }] : []), ]} placeholder={t('todo.noCategory')} size="sm" disabled={!canEdit} />
{canEdit && ( )}
) const dueField = (
onChange({ dueDate: v })} />
) return ( <>
{dialog ? (