// AK-P4b Interim-UI (AD-28) — "Neue Aufgabe" as a modal, mirroring the automation // list pattern (WF-P12 "Neue Automation starten"): creating a task is trivial enough // that a dialog on the list beats a dedicated page. Presentational only: the form // posts to the create route action (`createHref`) with the exact same field contract // as the standalone TaskNewPage, so the action stays untouched. No useLoaderData / // useFetcher (DoD A.5). Final Subframe optics land as a tracked design-nachzug. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherPlus, FeatherX } from "@subframe/core"; import type { TaskPriority } from "@hivegrid/view-models"; import { Button } from "~/ui/components/Button"; import { Dialog } from "~/ui/components/Dialog"; import { IconButton } from "~/ui/components/IconButton"; import { Select } from "~/ui/components/Select"; import { TextArea } from "~/ui/components/TextArea"; import { TextInput } from "~/ui/components/TextInput"; import { DateField } from "./DateField"; import type { TaskNewPrefill, TaskPickerOption } from "./TaskNewPage"; import { TASK_CREATOR_ASSIGNEE } from "./TaskNewPage"; const PRIORITIES: readonly TaskPriority[] = ["low", "normal", "high", "urgent"]; // The single assignee Select carries the kind in its value; the hidden // assigneeType/assigneeId inputs restore the action's field contract on submit. function assigneeValue(kind: "user" | "group", id: string): string { return `${kind}:${id}`; } export type TaskNewDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; /** Route that owns the create action (the standalone /tasks/new route). */ createHref: string; assignableUsers: readonly TaskPickerOption[]; assignableGroups: readonly TaskPickerOption[]; prefill?: TaskNewPrefill; }; export function TaskNewDialog({ open, onOpenChange, createHref, assignableUsers, assignableGroups, prefill = null, }: TaskNewDialogProps) { const { t } = useTranslation(); const [assignee, setAssignee] = useState(TASK_CREATOR_ASSIGNEE); const [assigneeType, assigneeId] = assignee === TASK_CREATOR_ASSIGNEE ? ["user", ""] : assignee.split(":"); return (
{t("tasks.new.title")} {t("tasks.new.subtitle")}
} aria-label={t("tasks.new.actions.cancel")} onClick={() => onOpenChange(false)} />
{prefill ? (
{t(`tasks.entity.${prefill.entityType}`)} · {prefill.entityId}
) : null}
); }