Allow zero canister or box count, but not both

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-20 10:52:07 +03:30
parent f44b14f82a
commit a5cb3ef35f
2 changed files with 11 additions and 5 deletions

View File

@@ -174,10 +174,14 @@ function showToast(message, isError = false) {
async function adjustCount(id, field, delta) {
const spanId = field === 'canister_count' ? `cc-${id}` : `bc-${id}`;
const otherId = field === 'canister_count' ? `bc-${id}` : `cc-${id}`;
const span = document.getElementById(spanId);
if (!span) return;
const next = parseInt(span.textContent, 10) + delta;
if (next < 1) return;
if (next < 0) return;
const other = document.getElementById(otherId);
const otherVal = other ? parseInt(other.textContent, 10) : 0;
if (next === 0 && otherVal === 0) return;
try {
const res = await fetch(`/api/orders/${id}`, {