diff --git a/components/forms/pricing-tiers.tsx b/components/forms/pricing-tiers.tsx
index 4789397..a1d3228 100644
--- a/components/forms/pricing-tiers.tsx
+++ b/components/forms/pricing-tiers.tsx
@@ -76,14 +76,12 @@ export const PricingTiers = ({
.sort((a, b) => (a?.minQuantity || 0) - (b?.minQuantity || 0))
.map((tier, sortedIndex) => {
if (!tier) return null;
-
- // Find the original index for proper event handling
- const originalIndex = pricing.findIndex(p =>
- p === tier || (p?.minQuantity === tier?.minQuantity && p?.pricePerUnit === tier?.pricePerUnit)
- );
+ // Prefer stable identifiers for mapping back to the original array
+ const keyId = tier._id || tier.tempId;
+ const originalIndex = pricing.findIndex((p) => (p?._id || p?.tempId) === keyId);
return (
= ({
const handleAddTier = () => {
setProductData((prev) => ({
...prev,
- pricing: [...prev.pricing, { minQuantity: 0, pricePerUnit: 0 }],
+ pricing: [
+ ...prev.pricing,
+ {
+ minQuantity: 0,
+ pricePerUnit: 0,
+ // tempId ensures stable identity before backend assigns _id
+ // Using crypto.randomUUID if available, otherwise a timestamp fallback
+ tempId:
+ (typeof crypto !== "undefined" && (crypto as any).randomUUID
+ ? (crypto as any).randomUUID()
+ : `${Date.now()}-${Math.random()}`),
+ },
+ ],
}));
};
diff --git a/public/git-info.json b/public/git-info.json
index 86dc10e..3002b22 100644
--- a/public/git-info.json
+++ b/public/git-info.json
@@ -1,4 +1,4 @@
{
- "commitHash": "72821e5",
- "buildTime": "2025-10-15T16:14:23.964Z"
+ "commitHash": "577c93d",
+ "buildTime": "2025-10-16T11:12:16.746Z"
}
\ No newline at end of file