When the server saved an inspection, harvest, treatment, feeding, varroa measurement or swarm check but the answer was lost (dead zone at the apiary), the form queued the entry and the sync later created it a second time - including a second automation task. Each opened form now creates one Idempotency-Key, sends it with the request and stores it with the queued entry, so the retry returns the first record. Entries queued before this change still sync without a key. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
33 lines
993 B
TypeScript
33 lines
993 B
TypeScript
import { apiFetch } from "@/lib/auth/api-client";
|
|
import { CreateOptions, idempotencyHeaders } from "@/lib/offline/idempotency";
|
|
import {
|
|
CreateVarroaMeasurementInput,
|
|
UpdateVarroaMeasurementInput,
|
|
VarroaMeasurement,
|
|
} from "./types";
|
|
|
|
export function fetchColonyVarroaMeasurements(colonyId: string): Promise<VarroaMeasurement[]> {
|
|
return apiFetch<VarroaMeasurement[]>(`/colonies/${colonyId}/varroa-measurements`);
|
|
}
|
|
|
|
export function createVarroaMeasurement(
|
|
input: CreateVarroaMeasurementInput,
|
|
options: CreateOptions = {},
|
|
): Promise<VarroaMeasurement> {
|
|
return apiFetch<VarroaMeasurement>("/varroa-measurements", {
|
|
method: "POST",
|
|
headers: idempotencyHeaders(options),
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function updateVarroaMeasurement(
|
|
id: string,
|
|
input: UpdateVarroaMeasurementInput,
|
|
): Promise<VarroaMeasurement> {
|
|
return apiFetch<VarroaMeasurement>(`/varroa-measurements/${id}`, {
|
|
method: "PATCH",
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|