feat(frontend): Koeniginnen-Views (Modul 4)
/queens: Liste; /queens/new: Anlegeformular; /queens/[id]: Bearbeiten (Zucht/Herkunft/Status/Notizen), "Volk zuweisen"-Dialog (nur ACTIVE Voelker zur Auswahl) und Volk-Historie. Bearbeitungsformular initialisiert Zustand direkt aus der geladenen Queen (gleiches Key-Reset-Pattern wie bei Apiaries/Colonies). Nav-Leiste und proxy.ts-Matcher um /queens erweitert. 10 Vitest-Tests, Lint, Typecheck und Build gruen. Kompletter Flow (Anlegen, Volk zuweisen, Historie) live im Browser gegen den echten Server verifiziert.
This commit is contained in:
1 parent
b18d61640d
commit
49ce23147c
12 files changed
+593
-2
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { apiFetch } from "@/lib/auth/api-client";
|
||||
import {
|
||||
AssignColonyInput,
|
||||
CreateQueenInput,
|
||||
Queen,
|
||||
QueenColonyHistoryEntry,
|
||||
UpdateQueenInput,
|
||||
} from "./types";
|
||||
|
||||
export function fetchQueens(): Promise<Queen[]> {
|
||||
return apiFetch<Queen[]>("/queens");
|
||||
}
|
||||
|
||||
export function fetchQueen(id: string): Promise<Queen> {
|
||||
return apiFetch<Queen>(`/queens/${id}`);
|
||||
}
|
||||
|
||||
export function fetchQueenHistory(id: string): Promise<QueenColonyHistoryEntry[]> {
|
||||
return apiFetch<QueenColonyHistoryEntry[]>(`/queens/${id}/history`);
|
||||
}
|
||||
|
||||
export function createQueen(input: CreateQueenInput): Promise<Queen> {
|
||||
return apiFetch<Queen>("/queens", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateQueen(id: string, input: UpdateQueenInput): Promise<Queen> {
|
||||
return apiFetch<Queen>(`/queens/${id}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function assignQueenColony(id: string, input: AssignColonyInput): Promise<Queen> {
|
||||
return apiFetch<Queen>(`/queens/${id}/assign-colony`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
export type QueenStatus =
|
||||
| "ACTIVE"
|
||||
| "RESERVE"
|
||||
| "UNMATED"
|
||||
| "MATED"
|
||||
| "LOST"
|
||||
| "REPLACED"
|
||||
| "SOLD"
|
||||
| "DECEASED";
|
||||
|
||||
export interface Queen {
|
||||
id: string;
|
||||
code: string;
|
||||
hatchYear: number | null;
|
||||
breed: string | null;
|
||||
origin: string | null;
|
||||
breeder: string | null;
|
||||
markingColor: string | null;
|
||||
markingNumber: string | null;
|
||||
matingType: string | null;
|
||||
matingStatus: string | null;
|
||||
inseminationData: string | null;
|
||||
motherLine: string | null;
|
||||
fatherLine: string | null;
|
||||
status: QueenStatus;
|
||||
notes: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deactivatedAt: string | null;
|
||||
}
|
||||
|
||||
export interface CreateQueenInput {
|
||||
code: string;
|
||||
breed?: string;
|
||||
origin?: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface UpdateQueenInput {
|
||||
breed?: string;
|
||||
origin?: string;
|
||||
notes?: string;
|
||||
status?: QueenStatus;
|
||||
}
|
||||
|
||||
export interface AssignColonyInput {
|
||||
colonyId: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface QueenColonyHistoryEntry {
|
||||
id: string;
|
||||
colonyId: string;
|
||||
startDate: string;
|
||||
endDate: string | null;
|
||||
notes: string | null;
|
||||
}
|
||||
Reference in new issue
Block a user