Fix admin adjust créditos WhatsApp: clamp silencioso vira erro vermelho
- Severidade dos toasts de validação: warn → error (não selecionar tenant, valor < 1, > WA_ADJUST_MAX, nada removível, excede max removível) - Remove :max do <InputNumber> no formulário — antes ele clampeava silenciosamente o valor digitado pro máximo permitido, escondendo o erro. Agora deixa o usuário digitar e estourar o toast vermelho do submit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -581,15 +581,15 @@ async function doWaAdjust() {
|
|||||||
|
|
||||||
function submitWaTopup() {
|
function submitWaTopup() {
|
||||||
const t = waTopup.value;
|
const t = waTopup.value;
|
||||||
if (!t.tenantId) { toast.add({ severity: 'warn', summary: 'Selecione o tenant', life: 2500 }); return; }
|
if (!t.tenantId) { toast.add({ severity: 'error', summary: 'Selecione o tenant', life: 2500 }); return; }
|
||||||
const amt = Math.round(Number(t.amount) || 0);
|
const amt = Math.round(Number(t.amount) || 0);
|
||||||
if (amt < 1) { toast.add({ severity: 'warn', summary: 'Valor deve ser >= 1', life: 2500 }); return; }
|
if (amt < 1) { toast.add({ severity: 'error', summary: 'Valor deve ser >= 1', life: 2500 }); return; }
|
||||||
if (amt > WA_ADJUST_MAX) { toast.add({ severity: 'warn', summary: `Máximo ${WA_ADJUST_MAX} por operação`, life: 3000 }); return; }
|
if (amt > WA_ADJUST_MAX) { toast.add({ severity: 'error', summary: `Máximo ${WA_ADJUST_MAX} por operação`, life: 3000 }); return; }
|
||||||
|
|
||||||
if (t.mode === 'remove') {
|
if (t.mode === 'remove') {
|
||||||
const max = waMaxAmountForMode();
|
const max = waMaxAmountForMode();
|
||||||
if (max <= 0) { toast.add({ severity: 'warn', summary: 'Nada removível', detail: 'Este tenant não tem créditos de cortesia disponíveis pra remoção.', life: 4000 }); return; }
|
if (max <= 0) { toast.add({ severity: 'error', summary: 'Nada removível', detail: 'Este tenant não tem créditos de cortesia disponíveis pra remoção.', life: 4000 }); return; }
|
||||||
if (amt > max) { toast.add({ severity: 'warn', summary: `Máximo removível: ${max}`, life: 3000 }); return; }
|
if (amt > max) { toast.add({ severity: 'error', summary: `Máximo removível: ${max}`, life: 3000 }); return; }
|
||||||
|
|
||||||
const msgItems = [
|
const msgItems = [
|
||||||
`Vai subtrair <strong>${amt} créditos</strong> de <strong>${escapeHtml(tenantName(t.tenantId))}</strong> (pool cortesia).`,
|
`Vai subtrair <strong>${amt} créditos</strong> de <strong>${escapeHtml(tenantName(t.tenantId))}</strong> (pool cortesia).`,
|
||||||
@@ -1045,7 +1045,7 @@ onMounted(() => {
|
|||||||
<label class="text-xs font-semibold uppercase tracking-wide text-[var(--text-color-secondary)]">
|
<label class="text-xs font-semibold uppercase tracking-wide text-[var(--text-color-secondary)]">
|
||||||
{{ waTopup.mode === 'remove' ? 'Créditos a remover' : 'Créditos a adicionar' }}
|
{{ waTopup.mode === 'remove' ? 'Créditos a remover' : 'Créditos a adicionar' }}
|
||||||
</label>
|
</label>
|
||||||
<InputNumber v-model="waTopup.amount" :min="1" :max="WA_ADJUST_MAX" class="w-full" fluid />
|
<InputNumber v-model="waTopup.amount" :min="1" class="w-full" fluid />
|
||||||
<small class="text-[var(--text-color-secondary)]">
|
<small class="text-[var(--text-color-secondary)]">
|
||||||
Máx. {{ WA_ADJUST_MAX }} por operação<span v-if="waTopup.mode === 'remove' && waRemovable"> · removível agora: {{ Math.min(WA_ADJUST_MAX, waRemovable.removable) }}</span>.
|
Máx. {{ WA_ADJUST_MAX }} por operação<span v-if="waTopup.mode === 'remove' && waRemovable"> · removível agora: {{ Math.min(WA_ADJUST_MAX, waRemovable.removable) }}</span>.
|
||||||
</small>
|
</small>
|
||||||
|
|||||||
Reference in New Issue
Block a user