Edit existing products
Adds PATCH /products/:id and an EditProductFlow modal opened from the product drawer. Editable fields cover name, brand, shop, bin, asset tag, price, purchase date, size (weight or count + unit weight), and the cannabinoid profile. SKU, type, kind, and status-derived dates stay locked because changing them would invalidate audit history math; type changes are surfaced as "mark gone, add new" in the modal. The strain row is re-resolved on name or brand change so analytics stay aligned, and the last-audit mirror (last_audit_weight / count_last_audit) only syncs with the original size when there are no audits yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,29 @@ export const api = {
|
||||
assetTag?: string;
|
||||
}) => request<{ id: string }>("/products", { method: "POST", body: JSON.stringify(body) }),
|
||||
|
||||
updateProduct: (
|
||||
id: string,
|
||||
body: Partial<{
|
||||
name: string;
|
||||
brandId: string | null;
|
||||
shopId: string | null;
|
||||
binId: string | null;
|
||||
assetTag: string | null;
|
||||
weight: number;
|
||||
countOriginal: number;
|
||||
unitWeight: number;
|
||||
price: number;
|
||||
thc: number;
|
||||
cbd: number;
|
||||
totalCannabinoids: number;
|
||||
purchaseDate: string;
|
||||
}>,
|
||||
) =>
|
||||
request<{ ok: true }>(`/products/${id}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
|
||||
finishProduct: (id: string, body: { date: string; rating?: number; notes?: string }) =>
|
||||
request<{ ok: true }>(`/products/${id}/finish`, {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user