feat(frontend): Aufgaben-Modul (Modul 6)
Aufgabenliste mit Status-/Prioritätsfilter und Erledigen-Aktion sowie Formular zum Anlegen neuer Aufgaben.
This commit is contained in:
1 parent
7bba168bd6
commit
632d382474
6 files changed
+357
-1
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { apiFetch } from "@/lib/auth/api-client";
|
||||
import { CreateTaskInput, Task, TaskFilter, UpdateTaskInput } from "./types";
|
||||
|
||||
export function fetchTasks(filter: TaskFilter): Promise<Task[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (filter.status) params.set("status", filter.status);
|
||||
if (filter.priority) params.set("priority", filter.priority);
|
||||
const query = params.toString();
|
||||
return apiFetch<Task[]>(`/tasks${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
export function createTask(input: CreateTaskInput): Promise<Task> {
|
||||
return apiFetch<Task>("/tasks", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateTask(id: string, input: UpdateTaskInput): Promise<Task> {
|
||||
return apiFetch<Task>(`/tasks/${id}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function completeTask(id: string): Promise<Task> {
|
||||
return apiFetch<Task>(`/tasks/${id}/complete`, { method: "POST" });
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
export type TaskStatus = "OPEN" | "IN_PROGRESS" | "DONE" | "CANCELLED";
|
||||
export type TaskPriority = "LOW" | "NORMAL" | "HIGH" | "URGENT";
|
||||
export type TaskRelatedType =
|
||||
| "COLONY"
|
||||
| "APIARY"
|
||||
| "QUEEN"
|
||||
| "HONEY_BATCH"
|
||||
| "STORAGE"
|
||||
| "GENERAL";
|
||||
|
||||
export interface Task {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string | null;
|
||||
priority: TaskPriority;
|
||||
dueDate: string | null;
|
||||
status: TaskStatus;
|
||||
assignedUserId: string | null;
|
||||
createdByUserId: string | null;
|
||||
relatedType: TaskRelatedType;
|
||||
relatedId: string | null;
|
||||
sourceInspectionId: string | null;
|
||||
createdAt: string;
|
||||
completedAt: string | null;
|
||||
}
|
||||
|
||||
export interface TaskFilter {
|
||||
status?: TaskStatus;
|
||||
priority?: TaskPriority;
|
||||
}
|
||||
|
||||
export interface CreateTaskInput {
|
||||
title: string;
|
||||
description?: string;
|
||||
priority?: TaskPriority;
|
||||
dueDate?: string;
|
||||
}
|
||||
|
||||
export interface UpdateTaskInput {
|
||||
title?: string;
|
||||
description?: string;
|
||||
priority?: TaskPriority;
|
||||
dueDate?: string;
|
||||
status?: TaskStatus;
|
||||
}
|
||||
Reference in new issue
Block a user