// AK-P4b Interim-UI (AD-28) — Task detail preview screen composed from ~/ui. // Presentational: renders the unwrapped TaskDetailData; mutations stay server-driven // (
+ intent, exactly like the baseline route action). The delete // confirmation is a real ~/ui Dialog (David standard), not a Card fake. No // useLoaderData / server imports. Final Subframe optics land as a design-nachzug. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherArchive, FeatherCheck, FeatherClipboard, FeatherSave, FeatherTrash2 } from "@subframe/core"; import type { TaskDetailData, TaskPriority, TaskStatus, TaskWatcherView } from "@hivegrid/view-models"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; 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 { APP_TIME_ZONE } from "~/locale/format"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell"; const STATUSES: readonly TaskStatus[] = ["open", "in_progress", "blocked", "done", "cancelled"]; const PRIORITIES: readonly TaskPriority[] = ["low", "normal", "high", "urgent"]; /** The one edit form; the header's save button targets it via `form=`. */ const TASK_EDIT_FORM_ID = "task-edit-form"; /** Sentinel for "do not add a watcher" — an empty Select value is not allowed. */ export const NO_WATCHER = "__none__"; function watcherRemoveFormId(userId: string): string { return `task-watcher-remove-${userId}`; } const sectionHeading = "text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary"; export type TaskDetailPageProps = { data: TaskDetailData; }; type BadgeFarbe = "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-neutral" | "subtle-information"; function priorityFarbe(priority: TaskPriority): BadgeFarbe { switch (priority) { case "urgent": return "subtle-negative"; case "high": return "subtle-warning"; case "normal": return "subtle-information"; case "low": default: return "subtle-neutral"; } } function statusFarbe(status: TaskStatus): BadgeFarbe { switch (status) { case "done": return "subtle-positive"; case "blocked": return "subtle-negative"; case "in_progress": return "subtle-warning"; case "cancelled": case "open": default: return "subtle-neutral"; } } function MetaRow({ label, value }: { label: string; value: string }) { return (
{label} {value}
); } function WatcherList({ watchers, canWrite, removeLabel, emptyLabel, }: { watchers: readonly TaskWatcherView[]; canWrite: boolean; removeLabel: string; emptyLabel: string; }) { if (watchers.length === 0) { return {emptyLabel}; } return ( ); } export function TaskDetailPage({ data }: TaskDetailPageProps) { const { t, i18n } = useTranslation(); const [deleteOpen, setDeleteOpen] = useState(false); const dateFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium" }); const deadlineLabel = data.deadlineIso ? dateFormatter.format(new Date(data.deadlineIso)) : "—"; return ( // Same page chrome as the lead detail: full-bleed header bar carrying icon, // title, status/priority badges and the action buttons, content below in // PageBody. Before this the screen started with a bare heading in a padded // div, which made it the only detail view without the app's header bar. } title={ {data.title} {t(data.statusKey)} {t(data.priorityKey)} } subtitle={t(data.sourceKey)} actions={ // Order: complete, archive, delete, save. "Erledigen" is the positive // outcome and gets the green variant; archive and save are ordinary // primary actions; delete keeps the destructive red. Save lives here // rather than at the bottom of the form: it is the single write for // every field below, reached via the `form` attribute. {data.canWrite && data.status !== "done" ? ( ) : null} {data.canWrite ? (
) : null} {data.canDelete ? ( ) : null} {data.canWrite ? ( ) : null}
} /> {/* Metadata */} {t("tasks.detail.section.overview")}
{data.linkedEntity ? (
) : null}
{data.description ? (
{t("tasks.detail.section.description")} {data.description}
) : null}
{/* Edit card (writers only): master data, assignment and watchers all in one tile, all written by the single save button in the header. Every control spans its grid cell so the tile's width is actually used. */} {data.canWrite ? ( {t("tasks.detail.section.edit")}
{/* --- Assignment --- */} {t("tasks.detail.section.assign")}
{/* --- Watchers: adding one is part of the same save; removing is not (it is a delete), so each remove button submits its own tiny form declared after this one via the `form` attribute. --- */} {t("tasks.detail.section.watchers")}
{data.assignableUsers.length > 0 ? ( ) : null}
{/* Remove-watcher forms live outside the edit form — nesting forms is invalid HTML, so the buttons above associate via `form=`. */} {data.watchers.map((watcher) => (
))}
) : ( {t("tasks.detail.section.watchers")}
)} {/* Delete confirmation dialog (real ~/ui Dialog, size XS) */}
{t("tasks.detail.delete.title")} {t("tasks.detail.delete.body")}
); }