// Add Product, Mark Consumed/Gone, Audit, Bins, Charts, Settings const AddProductFlow = ({data, onClose, onSave}) => { const [form, setForm] = React.useState({ name: "", brandId: data.brands[0].id, shopId: data.shops[0].id, type: "Flower", weight: 3.5, countOriginal: 1, unitWeight: 0.7, price: 45, thc: 22, cbd: 0.4, totalCannabinoids: 26, purchaseDate: "2026-04-25", binId: data.bins[0].id, sku: "", assetTag: "" }); const update = (k, v) => setForm(f => ({...f, [k]: v})); const cfg = data.types.find(t => t.id === form.type); const isDiscrete = cfg?.kind === "discrete"; const cpg = !isDiscrete && form.weight > 0 ? form.price / form.weight : 0; return (
e.stopPropagation()} style={{ width: "min(840px, 96vw)", margin: "40px 20px", background: "var(--bg)", border: "1px solid var(--line)", borderRadius: "var(--r-lg)", boxShadow: "var(--shadow-lg)" }}>
New entry

Add a product

Identity
update("name", e.target.value)} /> update("sku", e.target.value)} /> update("assetTag", e.target.value)} />
Acquisition
{isDiscrete ? ( <> update("countOriginal", +e.target.value)} /> update("unitWeight", +e.target.value)} /> ) : ( update("weight", +e.target.value)} /> )} update("price", +e.target.value)} /> update("purchaseDate", e.target.value)} />
{!isDiscrete && cpg > 0 && (
Cost per {cfg?.unit || "g"}: {fmt.money(cpg)}
)}
Cannabinoid profile
update("thc", +e.target.value)} /> update("cbd", +e.target.value)} /> update("totalCannabinoids", +e.target.value)} />
{form.name ? `"${form.name}" → ${data.bins.find(b=>b.id===form.binId)?.name}.` : "Fill in the name to continue."}
Cancel onSave(form)}>Save product
); }; // ─── CONSUME (mark finished) ────────────────────────────────────── const ConsumeFlow = ({data, onClose, product: initialProduct}) => { const active = data.products.filter(p => p.status === "active"); const [productId, setProductId] = React.useState(initialProduct?.id || active[0]?.id); const [rating, setRating] = React.useState(4); const [notes, setNotes] = React.useState(""); const [date, setDate] = React.useState("2026-04-25"); const product = data.products.find(p => p.id === productId); if (!product) return null; const bin = data.bins.find(b => b.id === product.binId); const lifespan = Math.round((new Date(date) - new Date(product.purchaseDate))/86400000); return (
e.stopPropagation()} style={{ width: "min(720px, 96vw)", margin: "40px 20px", background: "var(--bg)", border: "1px solid var(--line)", borderRadius: "var(--r-lg)", boxShadow: "var(--shadow-lg)" }}>
Archive · used up

Mark as finished

{product.name}
{H.brandName(data, product.brandId)} · {bin?.name} · purchased {fmt.dateShort(product.purchaseDate)}
LASTED
{lifespan} days
setDate(e.target.value)} />
{[1,2,3,4,5].map(n => ( ))} {rating}/5