Autofill next asset ID and pre-select bin from existing inventory
Build and push image / build (push) Successful in 55s
Build and push image / build (push) Successful in 55s
Asset tag field now defaults to the highest existing asset ID + 1. Bin selector pre-selects the bin where other instances of the same product are stored, falling back to the first bin. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -358,10 +358,18 @@ function InstanceDetailsStep({
|
|||||||
return last.price;
|
return last.price;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const [assetId, setAssetId] = useState("");
|
const nextAssetId = useMemo(() => {
|
||||||
|
const max = data.inventoryItems.reduce(
|
||||||
|
(m, i) => Math.max(m, parseInt(i.assetId, 10) || 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
return max > 0 ? String(max + 1).padStart(6, "0") : "";
|
||||||
|
}, [data.inventoryItems]);
|
||||||
|
|
||||||
|
const [assetId, setAssetId] = useState(nextAssetId);
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
shopId: last?.shopId ?? data.shops[0]?.id ?? NEW_SHOP,
|
shopId: last?.shopId ?? data.shops[0]?.id ?? NEW_SHOP,
|
||||||
binId: data.bins[0]?.id ?? NEW_BIN,
|
binId: last?.binId ?? data.bins[0]?.id ?? NEW_BIN,
|
||||||
weight: last?.weight ?? (isDiscrete ? 0 : 3.5),
|
weight: last?.weight ?? (isDiscrete ? 0 : 3.5),
|
||||||
unitWeight: last?.unitWeight ?? (isDiscrete ? 0.7 : 0),
|
unitWeight: last?.unitWeight ?? (isDiscrete ? 0.7 : 0),
|
||||||
price: initialPrice,
|
price: initialPrice,
|
||||||
|
|||||||
Reference in New Issue
Block a user