diff --git a/web/src/components/modals/AddInventoryFlow.tsx b/web/src/components/modals/AddInventoryFlow.tsx index 017859d..e8d1cb7 100644 --- a/web/src/components/modals/AddInventoryFlow.tsx +++ b/web/src/components/modals/AddInventoryFlow.tsx @@ -358,10 +358,18 @@ function InstanceDetailsStep({ 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({ 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), unitWeight: last?.unitWeight ?? (isDiscrete ? 0.7 : 0), price: initialPrice,