CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (push) Canceled after 0s
CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (pull_request) Canceled after 0s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (push) Canceled after 0s
CI / Core-Modul (Build/Vet/Test) (pull_request) Canceled after 0s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (pull_request) Canceled after 0s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (pull_request) Canceled after 0s
CI / Web (dms-browser) (pull_request) Canceled after 0s
CI / Core-Modul (Build/Vet/Test) (push) Canceled after 0s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (push) Canceled after 0s
CI / Web (dms-browser) (push) Canceled after 0s
CI / Web (pdf-viewer) (push) Canceled after 0s
CI / Web (shl) (push) Canceled after 0s
Supply-Chain-Scan (Go) / govulncheck (push) Canceled after 0s
Supply-Chain-Scan (npm) / npm-audit (push) Canceled after 0s
CI / Web (pdf-viewer) (pull_request) Canceled after 0s
CI / Web (shl) (pull_request) Canceled after 0s
Core-Schnittstellen-Vertragstests / contract-tests (pull_request) Canceled after 0s
Supply-Chain-Scan (Go) / govulncheck (pull_request) Canceled after 0s
Supply-Chain-Scan (npm) / npm-audit (pull_request) Canceled after 0s
Core-Pflichttest-Gate / pflichttest-gate (pull_request) Canceled after 0s
RBAC-Rollenhierarchie-Pflichtgate / rbac-policy-invariant (pull_request) Canceled after 0s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (pull_request) Canceled after 0s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (push) Canceled after 0s
Neue additive status-Spalte (open/in_progress/done) auf tasks,
status.go (SetStatus/ByStatus/GetStatus/ListAll) haelt completed_at
synchron fuer TSK-03s escalation.Store. Neuer HTTP-Layer taskapi
(GET /tasks, PATCH /tasks/{id}/status), Tenant-Kontext-Durchsetzung
wie backchannelapi (VOR-06). Neue Next.js-Oberflaeche
web/workflow-tasks (Liste + Kanban, Drag&Drop + Tastaturbedienung).
tasks-a11y-fixture fuer den echten Browser-Test, kein Produktions-
binary vorhanden das geaendert werden musste.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
// Duenner Client fuer die eigenen Backend-for-Frontend-Routen unter
|
|
// app/api — kein direkter Zugriff auf workflow/internal/taskapi vom Client
|
|
// aus, gleiches Muster wie web/routing-rules/web/workflow-cases.
|
|
|
|
export class ApiError extends Error {
|
|
status: number;
|
|
constructor(message: string, status: number) {
|
|
super(message);
|
|
this.status = status;
|
|
}
|
|
}
|
|
|
|
export type TaskStatus = "open" | "in_progress" | "done";
|
|
export type Priority = "low" | "normal" | "high";
|
|
|
|
export interface Reference {
|
|
ModuleName: string;
|
|
ObjectType: string;
|
|
ObjectID: string;
|
|
}
|
|
|
|
export interface Task {
|
|
ID: string;
|
|
Title: string;
|
|
AssigneeType: "person" | "group";
|
|
AssigneeID: string;
|
|
Priority: Priority;
|
|
References: Reference[] | null;
|
|
DueDate: string | null;
|
|
Status: TaskStatus;
|
|
}
|
|
|
|
async function handle<T>(res: Response): Promise<T> {
|
|
const body = await res.json().catch(() => null);
|
|
if (!res.ok) {
|
|
const message =
|
|
body && typeof body === "object" && "error" in body && typeof (body as { error: unknown }).error === "string"
|
|
? (body as { error: string }).error
|
|
: "Anfrage fehlgeschlagen";
|
|
throw new ApiError(message, res.status);
|
|
}
|
|
return body as T;
|
|
}
|
|
|
|
export async function listTasks(userId: string, tenantSlug: string): Promise<Task[]> {
|
|
const res = await fetch(
|
|
`/api/tasks?userId=${encodeURIComponent(userId)}&tenant=${encodeURIComponent(tenantSlug)}`,
|
|
{ cache: "no-store" }
|
|
);
|
|
return handle<Task[]>(res);
|
|
}
|
|
|
|
export async function setTaskStatus(
|
|
userId: string,
|
|
tenantSlug: string,
|
|
id: string,
|
|
status: TaskStatus
|
|
): Promise<void> {
|
|
const res = await fetch(
|
|
`/api/tasks/${encodeURIComponent(id)}/status?userId=${encodeURIComponent(userId)}&tenant=${encodeURIComponent(tenantSlug)}`,
|
|
{
|
|
method: "PATCH",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ status }),
|
|
}
|
|
);
|
|
if (res.status !== 204) {
|
|
await handle(res);
|
|
}
|
|
}
|
|
|
|
// Ueberfaellig (Akzeptanzkriterium 1): eine offene/in Bearbeitung befindliche
|
|
// Aufgabe mit einer Faelligkeit in der Vergangenheit. Erledigte Aufgaben
|
|
// gelten nie als ueberfaellig.
|
|
export function isOverdue(task: Task, now: Date = new Date()): boolean {
|
|
if (task.Status === "done" || !task.DueDate) {
|
|
return false;
|
|
}
|
|
return new Date(task.DueDate).getTime() < now.getTime();
|
|
}
|