feat(frontend): Abfuellungen und Produkte (Modul 23)
/products, /products/new, /bottling/new, /bottling/:id. Verbindung von der Honigcharge-Detailseite zur Abfuellung, Nav-Dropdown "Mehr" fuer alle Rollen mit Produkte/Abfuellungen erweitert.
This commit is contained in:
1 parent
e82cae257b
commit
f4df719df7
11 files changed
+568
-18
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { apiFetch } from "@/lib/auth/api-client";
|
||||
import { BottlingBatch, BottlingBatchFilter, CreateBottlingBatchInput } from "./types";
|
||||
|
||||
export function fetchBottlingBatches(
|
||||
filter: BottlingBatchFilter = {},
|
||||
): Promise<BottlingBatch[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (filter.honeyBatchId) params.set("honeyBatchId", filter.honeyBatchId);
|
||||
const query = params.toString();
|
||||
return apiFetch<BottlingBatch[]>(`/bottling-batches${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
export function fetchBottlingBatch(id: string): Promise<BottlingBatch> {
|
||||
return apiFetch<BottlingBatch>(`/bottling-batches/${id}`);
|
||||
}
|
||||
|
||||
export function createBottlingBatch(
|
||||
input: CreateBottlingBatchInput,
|
||||
): Promise<BottlingBatch> {
|
||||
return apiFetch<BottlingBatch>("/bottling-batches", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
export interface BottlingBatch {
|
||||
id: string;
|
||||
honeyBatchId: string;
|
||||
productId: string | null;
|
||||
date: string;
|
||||
jarSize: number;
|
||||
jarCount: number;
|
||||
totalAmount: number;
|
||||
bestBeforeDate: string;
|
||||
lotNumber: string;
|
||||
createdAt: string;
|
||||
honeyBatch: { id: string; batchNumber: string };
|
||||
product: { id: string; name: string } | null;
|
||||
}
|
||||
|
||||
export interface CreateBottlingBatchInput {
|
||||
honeyBatchId: string;
|
||||
productId?: string;
|
||||
date: string;
|
||||
jarSize: number;
|
||||
jarCount: number;
|
||||
bestBeforeDate: string;
|
||||
lotNumber: string;
|
||||
}
|
||||
|
||||
export interface BottlingBatchFilter {
|
||||
honeyBatchId?: string;
|
||||
}
|
||||
Reference in new issue
Block a user