Simplify consume modal: asset ID scan only
Build and push image / build (push) Successful in 44s

Remove eyebrow header, dropdown picker, and SKU matching.
Require scanning the physical asset ID to mark consumed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-04 19:22:10 -04:00
parent cb26a8e634
commit 50d61a78d5
+3 -21
View File
@@ -2,10 +2,9 @@ import { useState } from "react";
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import type { Bootstrap, Item } from "../../types.js"; import type { Bootstrap, Item } from "../../types.js";
import { helpers, TODAY_STR, enrichItems } from "../../types.js"; import { helpers, TODAY_STR, enrichItems } from "../../types.js";
import { remainingShort } from "../../stats.js";
import { fmt } from "../../format.js"; import { fmt } from "../../format.js";
import { api } from "../../api.js"; import { api } from "../../api.js";
import { Btn, Field, Icon, Input, Select, Textarea } from "../primitives/index.js"; import { Btn, Field, Icon, Input, Textarea } from "../primitives/index.js";
import { ScanField, type ScanResult } from "../ScanField.js"; import { ScanField, type ScanResult } from "../ScanField.js";
import { ModalBackdrop, ModalHeader, ModalFooter } from "./ModalChrome.js"; import { ModalBackdrop, ModalHeader, ModalFooter } from "./ModalChrome.js";
import { useToast } from "../Toast.js"; import { useToast } from "../Toast.js";
@@ -44,11 +43,6 @@ export function ConsumeFlow({
const handleScan = (result: ScanResult) => { const handleScan = (result: ScanResult) => {
if (result.kind === "item") { if (result.kind === "item") {
setItemId(result.item.id); setItemId(result.item.id);
} else {
const candidate = active
.filter((i) => i.productId === result.product.id)
.sort((a, b) => +new Date(b.purchaseDate) - +new Date(a.purchaseDate))[0];
if (candidate) setItemId(candidate.id);
} }
}; };
@@ -68,28 +62,16 @@ export function ConsumeFlow({
boxShadow: "var(--shadow-lg)", boxShadow: "var(--shadow-lg)",
}} }}
> >
<ModalHeader title="Mark as consumed" eyebrow="Archive · used up" onClose={onClose} /> <ModalHeader title="Mark as consumed" eyebrow="" onClose={onClose} />
<div style={{ padding: 32 }}> <div style={{ padding: 32 }}>
<ScanField <ScanField
items={active} items={active}
products={data.products} products={[]}
matchedLabel={item ? `${item.assetId} · ${item.name}` : null} matchedLabel={item ? `${item.assetId} · ${item.name}` : null}
onMatch={handleScan} onMatch={handleScan}
/> />
<div style={{ marginTop: 16 }}>
<Field label="Or pick from list">
<Select value={itemId} onChange={(e) => setItemId(e.target.value)}>
{active.map((i) => (
<option key={i.id} value={i.id}>
{i.assetId} · {i.name} {helpers.brandName(data, i.brandId)} ({remainingShort(i)} left)
</option>
))}
</Select>
</Field>
</div>
<div <div
style={{ style={{
marginTop: 16, marginTop: 16,