Prefill asset ID from last added item instead of global max
Build and push image / build (push) Successful in 43s
Build and push image / build (push) Successful in 43s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -359,11 +359,12 @@ function InstanceDetailsStep({
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
const nextAssetId = useMemo(() => {
|
const nextAssetId = useMemo(() => {
|
||||||
const max = data.inventoryItems.reduce(
|
if (data.inventoryItems.length === 0) return "";
|
||||||
(m, i) => Math.max(m, parseInt(i.assetId, 10) || 0),
|
const latest = data.inventoryItems.reduce((best, i) =>
|
||||||
0,
|
i.id > best.id ? i : best,
|
||||||
);
|
);
|
||||||
return max > 0 ? String(max + 1).padStart(6, "0") : "";
|
const num = parseInt(latest.assetId, 10);
|
||||||
|
return isNaN(num) ? "" : String(num + 1).padStart(6, "0");
|
||||||
}, [data.inventoryItems]);
|
}, [data.inventoryItems]);
|
||||||
|
|
||||||
const [assetId, setAssetId] = useState(nextAssetId);
|
const [assetId, setAssetId] = useState(nextAssetId);
|
||||||
|
|||||||
Reference in New Issue
Block a user