bug fixed

This commit is contained in:
Samandar Turgunboyev
2026-03-05 14:57:34 +05:00
parent 95d17b274f
commit 35374094eb
3 changed files with 72 additions and 28 deletions

View File

@@ -81,16 +81,18 @@ const ProductDetail = () => {
? 0
: Number(String(quantity).replace(',', '.'));
/* ---------------- HELPERS ---------------- */
const clampQuantity = (value: number) => {
if (isNaN(value)) return MIN_QTY;
let safe = Math.max(value, MIN_QTY);
safe = Math.min(safe);
let safe = value;
if (isGram) {
safe = Math.max(value, MIN_QTY);
safe = Math.ceil(safe / STEP) * STEP;
}
return safe;
};
const getQuantityMessage = (qty: number, measurement: string | null) => {
if (!measurement) return `${qty} dona`;
return `${qty} ${measurement}`;