Add bulk editing to inventory tab with atomic batch API
Build and push image / build (push) Successful in 1m3s
Build and push image / build (push) Successful in 1m3s
Multi-select inventory items via checkboxes (select-all, shift-click range, group header select) and apply bulk actions through a floating toolbar: edit fields (shop, bin, price, THC/CBD), consume, checkout, check in, and mark gone. Backend processes all operations in a single SQLite transaction for atomicity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import type { Bootstrap, AuditMode } from "./types.js";
|
||||
|
||||
export type BatchOp =
|
||||
| { action: "update"; id: string; fields: Partial<{ shopId: string | null; binId: string | null; price: number; thc: number; cbd: number; totalCannabinoids: number }> }
|
||||
| { action: "checkout"; id: string; date: string }
|
||||
| { action: "checkin"; id: string; date: string; binId: string }
|
||||
| { action: "finish"; id: string; date: string; rating?: number; notes?: string }
|
||||
| { action: "gone"; id: string; date: string; reason: string; notes?: string };
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const res = await fetch(`/api${path}`, {
|
||||
...init,
|
||||
@@ -146,6 +153,12 @@ export const api = {
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
|
||||
batchInventory: (ops: BatchOp[]) =>
|
||||
request<{ ok: true; count: number }>("/inventory/batch", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ ops }),
|
||||
}),
|
||||
|
||||
// Catalog tables (brand/shop/bin) — unchanged
|
||||
createBrand: (name: string) =>
|
||||
request<{ id: string; name: string }>("/brands", {
|
||||
|
||||
Reference in New Issue
Block a user