diff --git a/app/globals.css b/app/globals.css index 0aa6876..635d797 100644 --- a/app/globals.css +++ b/app/globals.css @@ -60,7 +60,7 @@ --z-admin-modal: 140; --z-whatsapp-modal: 2200; - --z-toast: 3000; + --z-toast: 11000; } * { @@ -5261,16 +5261,17 @@ body.modal-open { position: fixed; top: 0; bottom: 0; - left: 0; + right: 0; width: 85vw; max-width: 320px; background: var(--surface); z-index: 1001; - transform: translateX(-100%); + transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; - box-shadow: 20px 0 40px rgba(0,0,0,0.1); + box-shadow: -20px 0 40px rgba(0,0,0,0.1); + overflow-y: auto; } .vg-mobile-drawer.is-open { @@ -5327,8 +5328,6 @@ body.modal-open { .vg-drawer-categories { padding: 1.5rem; - overflow-y: auto; - flex: 1; } .vg-drawer-subtitle { diff --git a/components/admin/admin-product-modal.js b/components/admin/admin-product-modal.js index 628936a..c9a719d 100644 --- a/components/admin/admin-product-modal.js +++ b/components/admin/admin-product-modal.js @@ -141,8 +141,19 @@ export default function AdminProductModal() { function handlePriceFieldBlur(field) { setProductForm((prev) => { const rawValue = String(prev[field] ?? "").trim(); - if (!rawValue) return { ...prev, [field]: "" }; - return { ...prev, [field]: formatCurrencyInput(prev[field]) }; + const nextValue = rawValue ? formatCurrencyInput(rawValue) : ""; + + const otherField = field === "priceCash" ? "priceInstallment" : "priceCash"; + const otherValue = String(prev[otherField] ?? "").trim(); + + const nextForm = { ...prev, [field]: nextValue }; + + // Se preencheu um e o outro tá vazio, espelha pra facilitar + if (nextValue && !otherValue) { + nextForm[otherField] = nextValue; + } + + return nextForm; }); } @@ -168,6 +179,7 @@ export default function AdminProductModal() { function validatePayload(payload) { if (!payload.name || !payload.categoryId || !payload.subcategoryId) return "Nome, categoria e subcategoria são obrigatórios."; + if (payload.priceCash <= 0 || payload.priceInstallment <= 0) return "Preços à vista e a prazo devem ser maiores que zero."; if (!Array.isArray(payload.imageItems) || payload.imageItems.length === 0) return "Adicione ao menos uma imagem na galeria."; return ""; } @@ -270,7 +282,18 @@ export default function AdminProductModal() {