feat: warn against harvesting honey during a treatment's Wartezeit
Treatments (Ameisensäure, Oxalsäure, etc.) can require a legally mandated withdrawal period before honey from that colony may be sold. Nothing in the app tracked this before, so a beekeeper had no safeguard against harvesting into an active withdrawal window. Treatments now optionally record withdrawalPeriodDays (from the product's Packungsbeilage). The new harvest form fetches each candidate colony's active withdrawal window and shows an inline warning naming the product and the date it clears, computed as max(endDate ?? date) + withdrawalPeriodDays across a colony's treatments, restricted to windows still in the future. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
0881a38800
commit
d42f8331f9
13 files changed
+270
-56
No files matched your search
@@ -1,10 +1,26 @@
|
||||
import { apiFetch } from "@/lib/auth/api-client";
|
||||
import { CreateTreatmentInput, Treatment, UpdateTreatmentInput } from "./types";
|
||||
import {
|
||||
CreateTreatmentInput,
|
||||
Treatment,
|
||||
UpdateTreatmentInput,
|
||||
WithdrawalStatus,
|
||||
} from "./types";
|
||||
|
||||
export function fetchColonyTreatments(colonyId: string): Promise<Treatment[]> {
|
||||
return apiFetch<Treatment[]>(`/colonies/${colonyId}/treatments`);
|
||||
}
|
||||
|
||||
export function fetchWithdrawalStatus(
|
||||
colonyIds: string[],
|
||||
): Promise<WithdrawalStatus[]> {
|
||||
if (colonyIds.length === 0) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return apiFetch<WithdrawalStatus[]>(
|
||||
`/treatments/withdrawal-status?colonyIds=${colonyIds.join(",")}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function createTreatment(input: CreateTreatmentInput): Promise<Treatment> {
|
||||
return apiFetch<Treatment>("/treatments", {
|
||||
method: "POST",
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface Treatment {
|
||||
reason: string | null;
|
||||
batchNumber: string | null;
|
||||
notes: string | null;
|
||||
withdrawalPeriodDays: number | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
@@ -27,6 +28,7 @@ export interface CreateTreatmentInput {
|
||||
reason?: string;
|
||||
batchNumber?: string;
|
||||
notes?: string;
|
||||
withdrawalPeriodDays?: number;
|
||||
}
|
||||
|
||||
export interface UpdateTreatmentInput {
|
||||
@@ -40,4 +42,11 @@ export interface UpdateTreatmentInput {
|
||||
reason?: string;
|
||||
batchNumber?: string;
|
||||
notes?: string;
|
||||
withdrawalPeriodDays?: number;
|
||||
}
|
||||
|
||||
export interface WithdrawalStatus {
|
||||
colonyId: string;
|
||||
activeUntil: string;
|
||||
product: string;
|
||||
}
|
||||
Reference in new issue
Block a user